header - How do "nested" #includes work in C? -


lets there library/api or bunch of code want use (written else) , it's stored in arbitrary folder (like c:\randoapis\coolstuff\includes). let main.c in different folder c:\mycprojects\coolproject , use coolstuff api, add include path ide , add #include "coolstuff.h"; , works fine.

here's question:

lets "coolstuff.h" includes other header file #include "boringstuff.h"; where compiler look boringstuff.h? is in main.c folder? or in coolstuff's includes folder? any/all folders in include path? or compiler specific issue , should go read documentation

it implementation-defined. c11 6.10.2p3:

3 preprocessing directive of form

# include "q-char-sequence" new-line 

causes replacement of directive entire contents of source file identified specified sequence between " delimiters. the named source file searched in implementation-defined manner. if search not supported, or if search fails, directive reprocessed if read

# include <h-char-sequence> new-line 

with identical contained sequence (including > characters, if any) original directive.

notice #include "coolstuff.h" need not supported. additionally #include "coolstuff.h" can map #include <coolstuf.h>. c11 6.10.2p5:

5 implementation shall provide unique mappings sequences consisting of 1 or more nondigits or digits (6.4.2.1) followed period (.) , single nondigit. first character shall not digit. implementation may ignore distinctions of alphabetical case , restrict mapping 8 significant characters before period.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -