What does # Define mean ?

 

I have this in code:

#define SIGNAL_NONE 0

#define SIGNAL_BUY 1

#define SIGNAL_SELL 2

Could anyone tell me in laymans terms what this code does please ?

thanks in advance

 
#define DEF 0
function(DEF);
is equivalent to
function(0);
 
MickGlancy:

Could anyone tell me in laymans terms what this code does please ?

It doesn't "do" anything. It's a bit like the stuff in legal documents where it starts "This agreement between XYZ Incorporated Global Holdings Inc ('XYZ') ..." and then goes on to use XYZ throughout the rest of document rather than the full name, to make it more readable.

It means that later on in the code it can say something like:

if (CurrentSignal == SIGNAL_SELL)

...rather than...

if (CurrentSignal == 2)

...because the latter is much less clear. The first version makes the code much more readable and easier to understand and maintain.

 
thankyou, it really is simple.