Jump to content
  • Advertisement
Sign in to follow this  
Deyja

Preprocessor 0.5

This topic is 4836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!