ianshirm@zeno:~/glad/src$ make gcc -Wall -O -c -o glad.o glad.c In file included from glad.c:38: commands.h:55:1: error: pasting "CmdLeftHand" and "(" does not give a valid preprocessing token commands.h:56:1: error: pasting "CmdRightHand" and "(" does not give a valid preprocessing token commands.h:57:1: error: pasting "CmdFeet" and "(" does not give a valid preprocessing token commands.h:58:1: error: pasting "CmdEyes" and "(" does not give a valid preprocessing token commands.h:59:1: error: pasting "CmdQuit" and "(" does not give a valid preprocessing token commands.h:60:1: error: pasting "CmdShutdown" and "(" does not give a valid preprocessing token commands.h:61:1: error: pasting "CmdCreate" and "(" does not give a valid preprocessing token commands.h:62:1: error: pasting "CmdSay" and "(" does not give a valid preprocessing token commands.h:63:1: error: pasting "CmdChat" and "(" does not give a valid preprocessing token commands.h:64:1: error: pasting "CmdEmote" and "(" does not give a valid preprocessing token commands.h:65:1: error: pasting "CmdPrompt" and "(" does not give a valid preprocessing token commands.h:66:1: error: pasting "CmdCommands" and "(" does not give a valid preprocessing token commands.h:67:1: error: pasting "CmdWho" and "(" does not give a valid preprocessing token commands.h:68:1: error: pasting "CmdChallenge" and "(" does not give a valid preprocessing token commands.h:69:1: error: pasting "CmdAccept" and "(" does not give a valid preprocessing token commands.h:70:1: error: pasting "CmdTrain" and "(" does not give a valid preprocessing token commands.h:71:1: error: pasting "CmdLeave" and "(" does not give a valid preprocessing token commands.h:72:1: error: pasting "CmdStr" and "(" does not give a valid preprocessing token commands.h:73:1: error: pasting "CmdDex" and "(" does not give a valid preprocessing token commands.h:74:1: error: pasting "CmdSta" and "(" does not give a valid preprocessing token commands.h:75:1: error: pasting "CmdSiz" and "(" does not give a valid preprocessing token commands.h:76:1: error: pasting "CmdWit" and "(" does not give a valid preprocessing token commands.h:77:1: error: pasting "CmdScore" and "(" does not give a valid preprocessing token commands.h:78:1: error: pasting "CmdHelp" and "(" does not give a valid preprocessing token commands.h:79:1: error: pasting "CmdCredits" and "(" does not give a valid preprocessing token glad.c: In function 'main': glad.c:70: warning: implicit declaration of function 'time' glad.c: In function 'GameLoop': glad.c:149: warning: pointer targets in passing argument 3 of 'accept' differ in signedness glad.c: In function 'Log': glad.c:302: warning: implicit declaration of function 'ctime' glad.c:302: warning: format '%.24s' expects type 'char *', but argument 3 has type 'int' make: *** [glad.o] Error 1 ianshirm@zeno:~/glad/src$
11 Sep, 2009, David Haley wrote in the 2nd comment:
Votes: 0
This was covered recently. Don't have a ## between the name and the left parenthesis. (Not sure why it was there to begin with: somebody apparently didn't really understand how the preprocessor works.)
This was covered recently. Don't have a ## between the name and the left parenthesis. (Not sure why it was there to begin with: somebody apparently didn't really understand how the preprocessor works.)
It was there to reduce the size of the source code, and slipped through because it compiles and executes perfectly on older versions of gcc.
17 Sep, 2009, David Haley wrote in the 4th comment:
Votes: 0
How does that reduce the size of the source code? It actually looks like it's adding a character: you could delete the ## and replace with a single space. What am I not seeing?
Because "CMD(Quit)" is smaller than "CmdQuit(conn_t*pstConn,char*szCmd,char*szTxt)". Repeat that for every command, and it saves a fair few bytes. With retrospect and modern compilers it's clear that the second ## is unnecessary, but it compiled and executed fine at the time, and therefore slipped through unnoticed.
17 Sep, 2009, David Haley wrote in the 6th comment:
Votes: 0
No, I was talking about the macro specifically. I know that CMD(x) is shorter than the full prototype. I was asking why the ## was there; post #3 seemed to suggest that it was used to save space (as opposed to using a macro in general to save space). You still seem to suggest that the second ## was linked to reducing space, which is what's confusing me.
The macro as a whole was intended to save space - originally all the commands were written out in full, as CmdQuit(), etc, to avoid potential naming conflicts with other functions (much like Diku does with its "do_" prefix). I guess the "Cmd" part could have been dropped entirely, but it wasn't necessary to save quite that much space, I only needed to get the source code down to 16K.
Im trying to compile gladiator pits.. i get..