Solved Where do you store "header.h" files?

If I were to download or make my own header files that is included with quotation marks and not brackets, where do I put it for clang to find it correctly? Do I put it with the standard include files or do I put it in the same directory as my source file?

FreeBSD 9.1 and FreeBSD 11.0

thanks.
 
If the header file is only used during the build of your own application it should be kept there. But if you're building a library meant to be shared and client applications would need that header file in order to use your library /usr/local/include would be appropriate.

Note that FreeBSD 9.1 has been End-of-Life since December 2014 and is not supported any more.
 
If the header file is only used during the build of your own application it should be kept there. But if you're building a library meant to be shared and client applications would need that header file in order to use your library /usr/local/include would be appropriate.

Note that FreeBSD 9.1 has been End-of-Life since December 2014 and is not supported any more.
thanks a lot. Can I put my headers that would be in my source file directory in a folder in that directory or do all the .h and .c files need to be in the source file directory?
 
Can I put my headers that would be in my source file directory in a folder in that directory or do all the .h and .c files need to be in the source file directory?

You can put your header file into a subdirectory and specify that subdirectory in the include directive:
Code:
#include "sub_dir/header_file"

Or just use the basename of the header file in the include directive and tell the compiler where to find it. clang and gcc use the -I option:

Code:
clang -Isub_dir ...
 
Can I put my headers that would be in my source file directory in a folder in that directory or do all the .h and .c files need to be in the source file directory?
It's common to see the header files in the same directory as the source that needs it. But if you have a header file that's used in different source files in different directories it makes sense to put the header files in a common directory. It really doesn't matter where you put it as you can reference it with or without subdirectories. It's all a matter of keeping things organized.
 
Back
Top