Say I have a header file header.h
with an include guard that I #include
into my main.c
file:
#ifndef header_h
#define header_h
/* Maybe I define some things here, or mark some functions as extern "C", doesn't really matter */
#define PI 3.1415926535897932384
#ifndef COOL_PEOPLE
#define COOL_PEOPLE \
you, \
me
#endif
extern "C"
{
void a(void);
void b(int number);
}
#endif // header_h
Why is it that the definition of header_h
can be multiline without backslashes while I have to use backslashes to escape the newlines in the definition of COOL_PEOPLE
? For example, I don't need to do the following to get the include guard to work:
#ifndef header_h
#define header_h \
\
/* Maybe I define some things here, or mark some functions as extern "C", doesn't really matter */ \
\
#define PI 3.1415926535897932384 \
\
#ifndef COOL_PEOPLE \
#define COOL_PEOPLE \
you, \
me \
#endif \
\
extern "C" \
{ \
void a(void); \
void b(int number); \
} \
#endif // header_h
This has been confusing me ever since I found out about them, because in this way, include guards do not seem to act similar to other preprocessor macros. I tried looking around, but it was always about needing backslashes to make multiline macros in general. Is there something about the concept I'm not understanding?