opengl-tutorials / ogl

http://www.opengl-tutorial.org
2.69k stars 925 forks source link

Preprocessor conflict with tokens _B, _X, _S in AntTweakBar #138

Open DWesl opened 3 months ago

DWesl commented 3 months ago

https://gcc.gnu.org/onlinedocs/cpp/System-specific-Predefined-Macros.html https://en.cppreference.com/w/c/language/identifier#Reserved_identifiers Tokens beginning with an underscore and a capital letter are reserved for the system/compiler. AntTweakBar uses seven identifiers that are just the underscore and capital letter, at least three of which conflicted with preprocessor definitions.

I ran

sed -E -e 's/\b_B\b/_Blue/g' -e 's/\b_R\b/_Red/g' -e 's/\b_G\b/_Green/g' -e 's/\b_A\b/_Alpha/g' \
    -e 's/\b_S\b/_MixingFractionOfSecond/g' -e 's/\b_X\b/_ValueX/g' -e 's/\b_Y\b/_ValueY/g' \
    -i external/AntTweakBar-1.16/src/*.{h,cpp}

to make the names less likely to collide, otherwise I got a series of errors to the effect of "expected identifier before numeric literal" (and "identifier not declared in current scope" because it stopped parsing declarations when it ran into the previous error). The \b on either side is to prevent the script from changing OpenGL function names.