Hi ,I have a large cmake-based project which keeps report this compilation error:
<command-line>: error: expected identifier before numeric constant
compilation terminated due to -Wfatal-errors.
make[2]: *** [CMakeFiles/shonEM.dir/build.make:1986: CMakeFiles/shonEM.dir/lib/scene/common/vtk_ext/SCScalarBarActor.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
<command-line>: error: expected identifier before numeric constant
compilation terminated due to -Wfatal-errors.
make[2]: *** [CMakeFiles/shonEM.dir/build.make:2448: CMakeFiles/shonEM.dir/lib/scene/ui/VtkScene/SCVtkChartView.cpp.o] Error 1
,after a long time narrowing, I found that the
#include <vtkAxis.h>
caused this error,due to ,within this project ,adding “#include <vtkAxis.h>” to any file,and that file will throw this error. Removing all other content, only keep the “#include <vtkAxis.h>” ,corresponed cpp will throw this error also.
but
Same project with exact identical content will compiled successfully in other colleague’s machine.
and
And in my machine without any change ,if creating a brand new project with a single main.cpp which includes <vtkAxis.h> ,it will compile successfully and work fine.
And I doubt that some variable overwritings exist ,but since very limited error got thrown out
I suspect that this error occurs when “make” is scanning the header files to figure out the dependencies for the build. Try building in verbose mode to see if you can get more information about the error. You can do this by setting the VERBOSE environment variable when you run “make”:
VERBOSE=1 make
You can also try using ninja instead of make, by deleting the contents of your build directory and re-generating with “cmake -G Ninja”.
@dgobbi
Thanks,I found that a compilation option “-DPARALLEL” will be added automatically whether using single or multiple threads to compile.
And adding a #undef PARALLEL
before each #include <vtkAxis.h>
will solve this problem temporarily,but just a temporary way.