Gcc on cygwin doesn't like leading underscores in variable names

Alec Jacobson

May 06, 2013

weblog/

I recently tried to compile libigl on windows using cygwin, and got a myriad of errors of the form:
include/igl/draw_beach_ball.cpp:37:63: error: expected ‘,’ or ‘...’ before numeric constant
include/igl/draw_beach_ball.cpp: In function ‘const _T& TClamp(const _T&)’:
include/igl/draw_beach_ball.cpp:39:9: error: ‘_Limit1’ was not declared in this scope
include/igl/draw_beach_ball.cpp:39:17: error: ‘_Limit2’ was not declared in this scope
include/igl/draw_beach_ball.cpp: At global scope:
include/igl/draw_beach_ball.cpp:46:73: error: expected ‘,’ or ‘...’ before numeric constant
include/igl/draw_beach_ball.cpp: In function ‘color32 Color32FromARGBi(int, int, int, int)’:
include/igl/draw_beach_ball.cpp:48:40: error: no matching function for call to ‘TClamp(int&, int, int)’
include/igl/draw_beach_ball.cpp:48:78: error: no matching function for call to ‘TClamp(int&, int, int)’
include/igl/draw_beach_ball.cpp:48:116: error: no matching function for call to ‘TClamp(int&, int, int)’
include/igl/draw_beach_ball.cpp:48:152: error: no matching function for call to ‘TClamp(int, int, int)’
include/igl/draw_beach_ball.cpp: At global scope:
include/igl/draw_beach_ball.cpp:51:81: error: expected ‘,’ or ‘...’ before numeric constant
Turns out these were all due to the code we copied from AntTweakBar which used leading underscores before variable and template names. To fix it we just needed to change any variables like:
_FOO
to
FOO