🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Preprocessor 0.5

Started by
5 comments, last by WitchLord 18 years, 10 months ago
As always, it's in the same spot. NEW IN 0.5 Pragmas - Applications can register 'pragma callbacks' using the register_pragma functions. A pragma is a class derived from Preprocessor::PragmaCallback that implements the member function 'virtual void pragma(const PragmaInstance&)'. Pragmas are registered with a name and a PragmaCallback instance. Inside a script, you invoke a pragma with the syntax '#pragma name_of_pragma "text"'. The pragma registered with the specified name is called and receives information about the script calling the pragma in it's PragmaInstance parameter. This information includes the string, the current file, and the current line number. Implementing '#pragma once' is not recommended, and will not be as simple as you think. The filename reported by the PragmaInstance is not normalized. IE, it may contain constructs such as 'scripts/level1/../general/script.c'. This would happen if a script in scripts/level1 included another script using the relative path ../general/script.c. To implement #pragma once, you will have to resolve this issue yourself. Use inclusion guards instead. If you really must, Boost::filesystem may help. BugFix - #ifdef/#ifndef blocks - In rare cases where an the closing #endif of an excluded block was the last token in a file and not followed by a trailing newline, the preprocessor wrongly detected an unexpected end of file condition. Some IDE's automatically add a final newline if the file does not already have one, making this bug especially difficult to notice!
Advertisement
I'm guessing that the "text" parameter of the pragma is what is passed to the pragma handler?
Thumbs up! [grin]

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Yep. It would be better if it received a token list, but I felt a string would be a bit easier for people to handle. The third parameter must be a string literal, and it must be the final token on the line. The pragma callback recieves it with the quotes removed. Any other structure than '#pragma name "string"' will generate errors.

I added this just for you RainDog, so you wouldn't have to re-hack my code everytime I updated it. I remember you had added some sort of #import directive.

[edit]Oh, and WL, this update was prompted by that 'constants in switch statements' thread.[/edit]
Ok.

I won't have a chance to incorporate it a while. I have an interview with Microsoft for a Software Design Engineer in Test position(not a test engineer, the SDET position apparently *writes* the testing tools) that I need to study for.

[Edited by - Rain Dog on August 25, 2005 5:35:01 AM]
Good luck. Microsoft... wow!
Rain Dog:

Good luck, indeed! I hope you make it. [smile]

Deyja:

I have the constants in switch cases working already. So the preprocessor won't be necessary for this.

I'm pleased to see that you continue to work on the preprocessor as you see the need from others. This is what it takes to have a software tool become one of the best of its kind.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement