When looking at different interesting projects over at GitHub, I came across the following file:
https://github.com/charliesome/slash/blob/master/src/lib/regexp.c
It seems like he includes his own files the same way as standard headers:
#include <slash/lib/regexp.h>
Instead of this way:
#include "slash/lib/regexp.h"
I guess he changes the include path to make this possible, but my question is: why? Isn't the quote syntax made for situations like this (including your own header file)?
For projects of moderate size and in particular installable ones, it's often more convenient to store headers in a separate directory like include/
under the project root instead of next to the C files.
After adding this directory to the include path, the choice of <>
or ""
becomes a stylistic one -- ""
is only necessary for relative paths or if you add include directories via -iquote
instead of -I
, which is not particulary common.
An argument for using ""
would be to explicitly mark headers as project-specific.
An argument for using <>
would be that header inclusion will look the same in user and library code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With