Home AMX User Forum AMX Technical Discussion

Did #define work differently long ago?

So I am tasked with fixing this program(done by someone else I don't know how long ago) and I'm wondering how it ever even got installed like this...
DEFINE_CONSTANT

#define OPENING 			0
#define MAIN 				1
#define FULL_SCREEN_VIDEO	2
#define COMBINED			3
#define DIVIDED				4
#define LOCKOUT				5
....
(about 600 lines like this )

umm,
...

All over the place these -what are intended to be, I assume- constants are used in compare statements
if(someVar == COMBINED)

obviously they don't catch.

Client is just complaining that the thing freezes once in a while, but I don't see how any of this can be working ever... I'm afraid of what will happen if fix all those #defines with actual constant declarations.

Comments

  • BigsquatchBigsquatch Posts: 216
    travis wrote: »
    I'm afraid of what will happen if fix all those #defines with actual constant declarations.

    Step 1. Make a back up copy of all source code.

    #define is a pre-compiler directive. In other languages before the code is compiled the pre-compiler does a simple replacement of the the defined terms with the value assigned to them, so I would expect the #defines to work just fine.

    I doubt that the defines are causing the freezes.
Sign In or Register to comment.