Strange CPP error
moxie-coder opened this issue · 2 comments
moxie-coder commented
I was using some cpp code in haxe, and when compiling the code to cpp, this happens
include\flixel/input/keyboard/_FlxKey/FlxKey_Impl_.h(107): error C2059: syntax error: 'constant'
include\flixel/input/keyboard/_FlxKey/FlxKey_Impl_.h(107): error C2238: unexpected token(s) preceding ';'
include\flixel/util/_FlxColor/FlxColor_Impl_.h(58): error C2059: syntax error: 'constant'
include\flixel/util/_FlxColor/FlxColor_Impl_.h(58): error C2238: unexpected token(s) preceding ';'
this is the code I was using
#if windows
@:headerCode('
#include <windows.h>
#undef FALSE
#undef TRUE
#undef NO_ERROR
')
#end
I know I'm using flixel, but it might be an error involving hxcpp since this only happens during compiling
hughsando commented
Windows.h is terrible for defining things. "min" and "max" are common problems. "rad2" is also a problem. There are more in hxcpp/include/hx/Undefine.h - you may include to include this file after windows.h.
If you have a look at the lines mentioned in the error, you may need to add the variable names in the #undef.
moxie-coder commented
I managed to fix it, turns out
#undef TRUE
#undef FALSE
#undef NO_ERROR
it wasn't undefining for some reason, or unless I had undefined them the wrong way around, but either way it's fixed