#DEFINE warning

Aries

New Member
I occasionally use #DEFINE where a value can change depending on what code is compiled - #UNDEFINE allows me to redefine it, whereas once a SYMBOL is set it (as far as I know) cannot be unset.

I came across this oddity - the code is much simpler that what I was using, but it shows the problem:

#define CodeType 1 ' 1 = normal, 2 = test

b0 = CodeType
b1 = CodeType * 2
sertxd(#b0," ",#b1)
end

The printed result is:
1 1

whereas I would have expected
1 2

The reason is that the defined symbol CodeType includes the comment, so anything in the expression after it is ignored.

A word of warning, therefore, to those who - like me - comment their code

Roger
 

Attachments

Last edited:

techElder

Well-known member
Name: #define

Syntax:

#DEFINE label

#DEFINE label substitution

#DEFINE label(param1,param2...) substitution

Description:

The #define directive can be used in two ways -

1) To define a label to use in a #ifdef or #ifndef statements.

2) To define a single line substitution for use within the program.
The key to remember is that #define substitutes everything on the single line.

Now, a #macro allows much more flexibility.

I always comment my initial code lines on the line above starting full left.
 
Top