SA-MP Forums Archive
The difference between #define and const - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: The difference between #define and const (/showthread.php?tid=553470)



The difference between #define and const - Anuris - 29.12.2014

Hello guys.
I really want to know: what's the difference between #define and const?

Sorry for my English.


Re: The difference between #define and const - Vince - 29.12.2014

I've pondered over this myself a few times, because in a numerical context they aren't at all different. The only advantage I can think of using #define is that you can prepend it with a hash sign to turn it into a string. But that doesn't really work out if the number is between brackets (which it is in most cases).


Re: The difference between #define and const - iLuXing - 30.12.2014

#define POSITION 100.0, 200.0, 300.0
const position= [100.0, 200.0, 300.0];

SetPlayerPos(playerid, POSITION);
SetPlayerPos(playerid, position[0], position[1], position[2]);

no test.