Skip to content

Conversation

TBar09
Copy link

@TBar09 TBar09 commented Sep 30, 2025

(I have gotten permission to transfer this preprocessor code into codename-dev. The creator of all this code is @Redar13 from pull request #8, with a few touching ups by me.)

Fixes preprocessors (#if #else #end) & allows for version comparing.

#if(flixel >= "5.3.0")
import flixel.sound.FlxSound;
#else 
import flixel.system.FlxSound;
#end

#if(haxe >= "4.2.5")
trace("Haxe version is more than or equal to 4.2.5!");
#end

#if EXAMPLE_DEFINE
#error "This should produce an error"
#end

The following has been changed:

  • Preprocessor values set in the preprocessorValues map will be checked and accounted for; preprocessor values defined in the invalidPreprocessValues map will be considered false. The old preprocessor system only checked if the define existed.
  • Version checking using ==, >, >=, <, <=, !=.
  • The #error preprocessor is now usable (#error "This is an error").
  • Having a preprocessor statement with an empty body no longer produces an error.
  • parseString and parseModule now double checks the preprocStack for any lingering unclosed preprocessors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant