A problem involving #defines...
Displaying 1-11 of 11 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Interference22

I think #defines are broken. Check this out: I have the following in defines.vc:


#define gamename "Parallel Seven" // Name of the game
#define version "v1.0" // Version
#define fontheight 10 // The height of most in-game fonts
#define tportx 80 // X size of textbox portraits
#define tporty 65 // Y size of textbox portraits

#define inputfont 1
#define maxflags 1000 // Maximum number of flags
#define maxinvitems 300 // Total possible items the player can carry
#define maxpartysize 6 // Maximum number of partymembers

#define copyright "Copyright (c) 2004, Team Ultimate Disco Monkey" // The copyright notice


It seems valid to me but when I run VERGE it crashes. No error, not even a LOG. However, if I stick:

#define deffing "Defines are fucking broken"

...between the maxpartysize line and the copyright one it suddenly works. What the HELL is going on? I don't have any other defines in the whole code, so far as I know.

Also, I've traced this little oddity to another downright weird problem: at one point, I was not able to run my game in anything other than the directory I made it in. Messing with the defines suddenly made this problem go away.

Sorry I can't be any less vague about this, it IS proving to be an elusive little bugger to pinpoint.

Posted on 2004-06-23 23:07:14

Zip

I'm sure you won't be at all surprised to hear that adding that exact code to the to of my defines had no effect at all...

Zip

Posted on 2004-06-24 01:44:30

Gayo

No clue here, sorry. I've noticed some minor weirdnesses with #defines, but nothing that would explain this.

Posted on 2004-06-24 03:07:44

Overkill

I don't think that strings are fully compatible with #defines yet, and that could explain the oddity. Not exactly sure, though.

For the strings, since they don't need to be known before compilation, you could just set them to normal variables.


string gamename="Parallel Seven"; // Name of the game
string version="v1.0"; // Version
string copyright="Copyright (c) 2004, Team Ultimate Disco Monkey"; // The copyright notice

Posted on 2004-06-24 03:50:54

Interference22

I'm using #defines for convenience's sake and have been slowly converting the ones that point to strings to ACTUAL strings now, since that seems to be the only thing that fixes this problem aside from it randomly fixing itself when you insult it.

Posted on 2004-06-25 00:38:45

andy

I'm taking a bit of a guess here, but it's probably because the preprocessor is little more than a textual replecement mechanism. It grabs a token, and replaces any further occurrances of that token with EVERYTHING that comes after it.

Including those nice looking comments.

Try putting those comments before the #defines they describe.

(incidently, this is why textual preprocessors are a Very, Very Bad Idea)

Posted on 2004-06-25 00:44:47

Gayo

Hmm. I've not had any problems with comments on the same line as #defines.

Posted on 2004-06-25 04:26:33

geronimo

remember what grue once said about
#define DEBUG //
or something like that?

Posted on 2004-06-25 04:44:39

Zip

Nah, comments are stripped before the defines are dealt with. That's why you can't #define debug //

Zip

Posted on 2004-06-25 05:05:14

andy

As a sidenote, it doesn't handle blockquotes quite right:
#d MY_AWESOME_CONSTANT 1 /** Supa dupa constant

* Used for some supa dupa
* integrity checking.
*/

void autoexec() {}

Posted on 2004-06-25 05:11:04 (last edited on 2004-06-25 05:11:38)

mcgrue

Quote:Originally posted by geronimo

remember what grue once said about
#define DEBUG //
or something like that?


I mentioned that in passing as it came to me, but it was quickly shot down as not working.

Posted on 2004-06-25 05:26:55


Displaying 1-11 of 11 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.