Reputation: 1470
I've converted some legacy Fortran code to C using the f2c converter (f2c), and I've created a Visual Studio 10 solution using Cmake on Windows 7 (64-bit). I've also had to link my C++ program (test.cpp, containing my main function) with the f2c library (built on my system using nmake). Although I've worked extensively with CMake and Visual Studio, after compiling the program I'm now receiving a number of cryptic errors related to the header files shipped with Visual Studio:
2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\intrin.h(141): error C2059: syntax error : '('
2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\intrin.h(141): error C2059: syntax error : '-'
2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\intrin.h(141): error C2059: syntax error : ')'
2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xcomplex(250): error C2027: use of undefined type '_Ty'
2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xcomplex(250): error C2226: syntax error : unexpected type 'std::complex<_Other>'
2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xcomplex(250): error C2988: unrecognizable template declaration/definition
2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xcomplex(250): error C2059: syntax error : '-'
2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xcomplex(250): error C2065: '_Ty' : undeclared identifier
2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xcomplex(250): error C2059: syntax error : ')'
2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xcomplex(263): error C2065: '_Ty' : undeclared identifier
2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xcomplex(263): error C2065: '_Ty' : undeclared identifier
2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xcomplex(264): error C2143: syntax error : missing ';' before '{'
2>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xcomplex(264): error C2447: '{' : missing function header (old-style formal list?)
Creating a Visual Studio solution file from scratch doesn't seem to work very well either, and I am still receiving the same errors. What can I do to track down the issue with these errors? Obviously something is wrong with the files that I've included or written, but what could it be? The errors don't immediately point to a certain section of the code, so debugging is challenging.
Here is a link to the f2c.h header file (f2c.h). I've added
#ifdef __cplusplus
extern "C" {
#endif
to the top and
#ifdef __cplusplus
}
#endi
to the bottom of this header file, since my test.cpp is a C++ program.
Upvotes: 1
Views: 3935
Reputation: 22683
It seems the problem is that f2c.h
defines a number of macros, including some for math functions such as abs
. These macros cause problems when those same identifiers are encountered in the standard headers.
For this reason, I recommend that you always include f2c.h
as the last header in the file (or #undef
the conflicting macros before including other files).
Upvotes: 2