0 Members and 4 Guests are viewing this topic.
In other news, Frey continues kicking unprecedented levels of ass.
The addition of preprocessor conditionals was awesome, and I will find it very useful. But could there also be something similar to #ifdef? It would be useful for Axe libraries that allow the user to customize them by including defines in their own source code, and the library can fill in any defines with default values if the user didn't define them. The obvious solution would be a new command that determines whether or not the constant is defined. If you don't want to add a new command, you could also try something like the standard preprocessor conditional, but with the constant being used in a trivial comparison, like this:...!If °Size≥08→°Size...
kind of like 3d
I'm not so sure if I want an "IfDef" type command. What's wrong with just defining a constant as 0 or -1 if its going to be unused? Other than typing slightly less in some cases, it really doesn't offer an advantage over regular if statements.
But that doesn't work if you want to have several programs with repeated data in them that you don't want duplicated when you compile them into one program.
Quote from: Quigibo on January 02, 2012, 07:50:36 pmI'm not so sure if I want an "IfDef" type command. What's wrong with just defining a constant as 0 or -1 if its going to be unused? Other than typing slightly less in some cases, it really doesn't offer an advantage over regular if statements.The main purpose I can think of is, as I suggested in my original post, Axe libraries. Say you want to write a killer tilemapping library. You may need a bunch of different options to make it really versatile: tile width, tile height, black and white or grayscale, bits per tile, compression scheme, tileset pointer location, map pointer location, read from archive ability, smooth or rough scrolling, custom/variable buffer pointer, animated tile support... the list could go on. Being a true library, it's not proper to edit the library file itself. The user should specify customization settings in their own program.Without something like an #ifdef, you would have to force the programmer to define a dozen different constants for features they don't need, or don't even know exist. If a new feature was added to the library down the road, their program would instantly be broken because it would need a new constant defined. And including all of these constants in their source would cause unnecessary headaches and source bloat that could be a hundred bytes or more.