• C

#ifdef BOB

if I have
#ifdef BOB

in a c file.  Is there any other way to get the printf statement to be compiled other than with this line code
#define BOB 10

some where in the path of compilation.
Who is Participating?
dhaineaultConnect With a Mentor Commented:
Well first of all, if you are using BOB simply as a pre-compiler tag, you do not need a value.

eg #define BOB

....would be sufficient.

As far as another way, most compilers support the -D option (or a variation) at the command line.

For example, under UNIX:

cc -DBOB myfile.c  [...other parameters]

....defines BOB for compilation (note that there is no space between "D" and "BOB")
bcarderAuthor Commented:
Edited text of question.
bcarderAuthor Commented:
Thanks, I didn't know about the -D option.  That was where I need to look.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.