I’m reading external C code, and I found the following line of code:
#define __MAIN_C__
where #define is given only one “argument” (namely __MAIN_C__).
Is this just a placeholder, or can it have a function?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That
#definewill define__MAIN_C__to no value (thanks to n.m. and a simple test program). It’s a shortcut when you need something#defined when you don’t care what it’s defined to. In that case, somewhere in your code, you’d probably just see:And that doesn’t care what specific value it has, as long as it’s defined (and perhaps nonzero).
You’ll very often see this for include guards, like so:
This is similar to doing this in the compile flags:
If you want to see that it’s defined to nothing, try to compile this and watch it fail: