🎉 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!

bug with switch

Started by
1 comment, last by SergSerg 16 years, 9 months ago
in the app: r = pEngine->RegisterGlobalProperty("const int FIELDTYPE_ENUMERATION",&asCHelper::FIELDTYPE_ENUMERATION); in the script: switch(xxx) { case FIELDTYPE_ENUMERATION: .... } Error: case expression must be constant. Is that a bug ?
Advertisement
No, it's not a bug. The registered FIELDTYPE_ENUMERATION property is not considered a constant (although it is considered read-only from the script side).

You need to declare the const variable in the script for the compiler to consider is a valid constant in a switch case. E.g:

const char *cnst = "const int FIELDTYPE_ENUMERATION = 1;";pEngine->AddScriptSection(0, cnst, strlen(cnst));... add the other script sectionspEngine->Build(0);


I'll improve this in the future of course.

Regards,
Andreas

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

Clear.
Big thanx.

This topic is closed to new replies.

Advertisement