2

Trying to apply a default value in my code when compiling the file.

I need to set a defined key word to a certain value in my code.

So when I compile the code and it doesn't receive any definition in the arguments of the compiler it will use my default value.

I'm not to sure on how to do this, but I got a little idea:

#ifndef MAXWORKLOAD
#define MAXWORKLOAD 10
#endif

So if I put this in the code and I use this command line in the argument:

gcc -W -Wall 

It will use 10 has default?

And if I use this command line on the compilation:

gcc -W -Wall -DMAXWORKLOAD=5

It will use the 5 as its new setting?

I'm not too clear from reading the documentation on this.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Cyberflow
  • 1,255
  • 5
  • 14
  • 24

1 Answers1

8

Not sure how else to answer this question but...

Yes, that's right.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Ben Wainwright
  • 4,224
  • 1
  • 18
  • 36