*.h files....where to put them for #include
i have *.h files that i want to access when writing in c. i run redhat 8 and was wondering where should i put the files?
thanks for your help =] |
these are header files you have just created yourself? you can specify code to use a local relative path by using #include "header.h" rather than #include <header> this will then look for the h file in your current directory.
|
If you want to have the header files in a different directory, you might find it easier to use the -I[include dir] option of gcc and <> brackets in the #include. This way, you don't have to keep typing the full path of the header in your source files.
Alex |
I would suggest using acid_kewpie's route. When you start writing for a new project, create a directory for it, then an "include" subdirectory. Any header files you create can be referenced like:
#include "include/header.h" llama_meme's suggestion will work too. If you revisit the code later though, you may not remember header files were included on the command line. It's not intuitive (for me at least) to look there for it. |
Quote:
when trying to re-use code ;) Cheers, Tink |
Yep, Makefiles are great.
I'm quite <ahem> retentive though when it comes to programming style. Something about a computer science instructor, a LARGE crowbar, and lots of bruises... it's all kind of blurry... can't imagine why... but I digress... I just can't convince myself to remove the paths from include statements. When I look at source code and come across something (like a typedef, #ifdef statements, and the like), then I like to jump to the top of the file and know exactly where to look for where all that stuff is defined. Ease of access to information... it's all about fewer files to look in... :) |
whats the default directory the compiler looks in for '#include <blah.h>'
im just learning C going very slowly. bare with me. =) |
Depends on how your system is set up. The only one you can be sure of is /usr/include.
Alex |
All times are GMT -5. The time now is 01:25 PM. |