Reputation: 570
I am using CMake with Visual Studio and I keep getting the error yvals_core.h(23): fatal error C1189: #error: STL1003: Unexpected compiler, expected C++ compiler.
This error only happened after I moved all my includes to my precompiled header. It looks like the __cplusplus
macro is not defined for some reason.
More information: I just have a header file including all the includes I need. Then I just added that header file to the precompiled header by using target_precompile_headers
Upvotes: 2
Views: 13637
Reputation: 732
Library iostream
should stay in the files. The problem is with extension of code files - it should be .cpp
, not .c
. You don't need to remove iostream
. But then use other command to compile+link, not:
cl perfdata.c -o perfdata -lpdh
but use this one:
cl perfdata.cpp /link pdh.lib
(That's an example)
Upvotes: 0
Reputation: 506
I got a very similar error when compiling with a MSVC2019 compiler (14.29.30133) with VS2022, where the includes paths were still pointing to the 2022 version.
I could fix this error by passing "-vcvars_ver=14.29.30133" as argument to the vcvars64.bat script which sets up the environment, so that everything is consistent (on the older version).
Upvotes: 0
Reputation: 403
I got this error in MS Visual Studio 2022 with a C project that mistakenly included <iostream>
Removing this fixed the issue.
Upvotes: 1
Reputation: 31
I have recently experienced the same issue.
I noticed that the iostream.h library used for C++ was included in a .c file within my program. Once I removed this include directive (#include <iostream.h>) the error was resolved.
Check all the include directives within the program and verify them for correctness. Please let me know if this helps.
Upvotes: 3