Clang++ 4.0.0 compilation error in windows - c++

I'm using clang 4.0.0 compiled from source on windows 10 (32-bit OS, x86 processor). I'm trying to compile my cpp code to llvm ir code of the format ll.
Here's a sample code which fails to compile using clang:
#include <windows.h>
#include <tlhelp32.h>
#include <fstream>
#include <mapi.h>
#include <memory>
#include<stdio.h>
/* Function to calculate x raised to the power y */
int power(int x, unsigned int y)
{
if (y == 0)
return 1;
else if (y%2 == 0)
return power(x, y/2)*power(x, y/2);
else
return x*power(x, y/2)*power(x, y/2);
}
/* Program to test function power */
int main()
{
int x = 2;
unsigned int y = 3;
printf("%d", power(x, y));
return 0;
}
This is just a sample code, but it's the same behavior across all c++ code which include the listed header files.
I use the following command to compile it to llvm ir code:
clang++ -S -emit-llvm assiral.cpp -o assiral.ll
On compilation I get the following error:
C:\Sample>clang++ -emit-llvm -S assiral.cpp -o assiral.ll
In file included from assiral.cpp:3:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\fstream:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\includem:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\ostream:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\ios:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xlocnum:7:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\cmath:617:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xtgmath.h:9:
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xtr1common:204:22: error:
use of undeclared identifier 'char16_t'
struct _Is_integral<char16_t>
^
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xtr1common:210:22: error:
use of undeclared identifier 'char32_t'
struct _Is_integral<char32_t>
^
In file included from assiral.cpp:3:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\fstream:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\includem:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\ostream:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\ios:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xlocnum:10:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\streambuf:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xiosbase:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xlocale:8:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\stdexcept:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\exception:7:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\type_traits:6:
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xstddef:257:2: error: 'auto'
return without trailing return type; deduced return types are a C++14 extension
auto _Unfancy(_Ptrty _Ptr)
^
In file included from assiral.cpp:3:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\fstream:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\includem:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\ostream:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\ios:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xlocnum:10:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\streambuf:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xiosbase:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xlocale:8:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\stdexcept:7:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xstring:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xmemory0:8:
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\limits:612:33: error: use of
undeclared identifier 'char16_t'
template<> class numeric_limits<char16_t>
^
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\limits:902:33: error: use of
undeclared identifier 'char32_t'
template<> class numeric_limits<char32_t>
^
In file included from assiral.cpp:3:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\fstream:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\includem:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\ostream:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\ios:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xlocnum:10:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\streambuf:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xiosbase:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xlocale:8:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\stdexcept:7:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xstring:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xmemory0:10:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xutility:8:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\utility:7:
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\iosfwd:254:21: error: use of
undeclared identifier 'char16_t'
struct char_traits<char16_t>
^
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\iosfwd:263:21: error: use of
undeclared identifier 'char32_t'
struct char_traits<char32_t>
^
In file included from assiral.cpp:3:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\fstream:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\includem:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\ostream:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\ios:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xlocnum:10:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\streambuf:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xiosbase:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xlocale:8:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\stdexcept:7:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xstring:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xmemory0:10:
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xutility:698:2: error:
'auto' return without trailing return type; deduced return types are a C++14 extension
auto _Unchecked_n(_Iter _Src, _Diff)
^
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xutility:742:2: error:
'auto' return without trailing return type; deduced return types are a C++14 extension
auto _Unchecked_n_backward(_Iter _Src, _Diff)
^
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xutility:1142:12: error:
deduced return types are a C++14 extension
constexpr decltype(auto) _Operator_arrow(_Iterator&& _Target, false_type)
^
In file included from assiral.cpp:3:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\fstream:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\includem:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\ostream:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\ios:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xlocnum:10:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\streambuf:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xiosbase:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xlocale:8:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\stdexcept:7:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xstring:6:
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xmemory0:356:2: error:
'auto' return without trailing return type; deduced return types are a C++14 extension
auto _Const_cast(_Ptrty _Ptr)
^
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xmemory0:366:2: error:
'auto' return without trailing return type; deduced return types are a C++14 extension
auto _Const_cast(_Ty * _Ptr)
^
In file included from assiral.cpp:3:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\fstream:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\includem:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\ostream:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\ios:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xlocnum:10:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\streambuf:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xiosbase:6:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xlocale:8:
In file included from C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\stdexcept:7:
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xstring:75:2: error:
statement not allowed in constexpr function
for (auto _Match_try = _Haystack + _Start_at; ; ++_Match_try)
^
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xstring:119:3: error:
statement not allowed in constexpr function
for (auto _Match_try = _Haystack + _Min_value(_Start_at, _Hay_size - _Needle_size); ; --_Match_try)
^
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xstring:144:3: error:
statement not allowed in constexpr function
for (auto _Match_try = _Haystack + _Min_value(_Start_at, _Hay_size - 1); ; --_Match_try)
^
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xstring:169:3: error:
statement not allowed in constexpr function
for (auto _Match_try = _Haystack + _Start_at; _Match_try < _End; ++_Match_try)
^
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xstring:188:3: error:
statement not allowed in constexpr function
for (auto _Match_try = _Haystack + _Min_value(_Start_at, _Hay_size - 1); ; --_Match_try)
^
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xstring:213:3: error:
statement not allowed in constexpr function
for (auto _Match_try = _Haystack + _Start_at; _Match_try < _End; ++_Match_try)
^
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\xstring:233:3: error:
statement not allowed in constexpr function
for (auto _Match_try = _Haystack + _Start_at; _Match_try < _End; ++_Match_try)
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
What I expect after running the command is to have the bytecode file generated (.ll file). I've seen many posts where they introduce a flag : '-fms-compatibility-version=19' along with the command. However the flag added gets flagged as an unknown argument. I'm working with MSVS 2017. Maybe I'm using this flag wrong. But I've been at this impasse for a day now. Any help or suggestion would be greatly appreciated.

This was fixed by adding the correct path to the header files in the environment variable INCLUDE. Most of my errors were resolved once I fixed the paths. This includes the error where compiling a c++ file which references certain headers like windows.h gives a file not found.
Link on how to do the same : List all environment variables from command line?
You can also fix another issue which is :
link fatal error lnk1104 cannot open file 'libcmt.lib'
by setting the LIBPATH environment variable to point to the right location of the libcmt.lib file. I found mine at:
C:\Program Files\Microsoft Visual Studio 14.0\VC\lib
These trivial issues left me spending quite a few days to figure out. Hope this saves someone the same trouble.

Related

CMake uses C-style precompiled headers instead of C++ version of the precompiled header

My project directory is as follows:
<PROJECT-ROOT>:
- build
- MyProject:
- src:
- main.cpp
- hello.h (basic file that contains a simple function that prints something using iostream)
- pch.h (precompiled header)
- CMakeLists.txt
And CMakeLists.txt file is as follows:
cmake_minimum_required(VERSION 3.16)
project(MyProject)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -std=c++11")
endif()
include_directories(
MyProject
MyProject/src
)
add_executable(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/MyProject/pch.h
${CMAKE_SOURCE_DIR}/MyProject/src/main.cpp
${CMAKE_SOURCE_DIR}/MyProject/src/hello.h)
target_precompile_headers(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/MyProject/pch.h)
As expected, CMake generates the following precompiled header files in build/CMakeFiles/MyProject.dir/ :
cmake_pch.c
cmake_pch.cxx
cmake_pch.cxx.obj
cmake_pch_cxx.pch
cmake_pch.h
cmake_pch.hxx
I am using this CMake project in Visual Studio 2019, and when I try to run main.cpp, Visual Studio gives me a bunch of errors, such as:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\cstdlib(23): error C2061: syntax error: identifier 'noexcept'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\cstdlib(23): error C2059: syntax error: ';'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\cstdlib(23): error C2449: found '{' at file scope (missing function header?)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\cstdlib(25): error C2059: syntax error: '}'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\cstdlib(31): error C2061: syntax error: identifier 'noexcept'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\cstdlib(31): error C2059: syntax error: ';'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\cstdlib(31): error C2449: found '{' at file scope (missing function header?)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\cstdlib(33): error C2059: syntax error: '}'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xtr1common(19): error C2061: syntax error: identifier 'std'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xtr1common(19): error C2059: syntax error: ';'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xtr1common(19): error C2449: found '{' at file scope (missing function header?)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xtr1common(235): error C2059: syntax error: '}'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\iosfwd(175): warning C4157: pragma was ignored by C compiler
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\iosfwd(180): warning C4157: pragma was ignored by C compiler
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\type_traits(307): error C4233: nonstandard extension used: '__is_union' keyword only supported in C++, not C
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\type_traits(310): error C4233: nonstandard extension used: '__is_union' keyword only supported in C++, not C
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\type_traits(313): error C4233: nonstandard extension used: '__is_class' keyword only supported in C++, not C
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\type_traits(316): error C4233: nonstandard extension used: '__is_class' keyword only supported in C++, not C
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\type_traits(325): error C4233: nonstandard extension used: '__is_convertible_to' keyword only supported in C++, not C
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\type_traits(330): error C4233: nonstandard extension used: '__is_convertible_to' keyword only supported in C++, not C
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\type_traits(359): error C4233: nonstandard extension used: '__is_enum' keyword only supported in C++, not C
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\type_traits(362): error C4233: nonstandard extension used: '__is_enum' keyword only supported in C++, not C
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\type_traits(499): error C4233: nonstandard extension used: '__is_pod' keyword only supported in C++, not C
When I searched error code C4233 online, I learned that it is because a C code is trying to be compiled as a C++ code. Also, build process from Visual Studio (I guess uses ninja) shows that:
[1/33] Building C object CMakeFiles\MyProject.dir\cmake_pch.c.obj
Hence, I guess it tries to build my precompiled header as a c source, instead it is a C++ source. I also tried to change the pch extension to .hpp but it didn't work either. How can I specify CMake to mark precompiled header as C++ (or I guess CXX) source instead of pure C?
EDIT: When I disable the target_precompile_headers the program runs fine, hence I am certain that this is a precompiled header issue.
Thanks to #drescherjm, adding target_precompile_headers(${PROJECT_NAME} PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_SOURCE_DIR}/MyProject/pch.h>" got rid of the errors.

Windows - only the first entry of PATH-environment variable can be found

The following problem with my PATH-environment variable I have for some time, and it's become untolerable annoying so I would appreciate help a lot.
The following is the content of my system environment variables, which is also the output of echo %PATH% on cmd-exe.
C:\MinGW\bin; C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin; C:\msys\1.0\bin; C:\Qt\5.3\msvc2013_64\bin; C:\Users\Public\Documents\Embarcadero\Studio\15.0\Bpl;C:\Program Files (x86)\Embarcadero\Studio\15.0\bin64;C:\Users\Public\Documents\Embarcadero\Studio\15.0\Bpl\Win64;C:\Program Files\doxygen\bin;%ANT_HOME%\bin; %JAVA_HOME%\bin; %M2_HOME%\bin; C:\Program Files (x86)\MiKTeX 2.8\miktex\bin; C:\Program Files\PDF Split And Merge Basic\bin; C:\Program Files\Microsoft\Web Platform Installer; C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn;C:\Program Files (x86)\Windows Live\Shared;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\SlikSvn\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\doxygen\bin
The thing is now, that only the first entry of this can be used, i.e the command "g++" (which is in C:\MinGW\bin ) can be found, but already the command "cl" (which is in C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin) can't be found, and all subsequent commands also not.
What am I doing wrong?

clang and <iostream> on windows

According to http://clang.llvm.org/get_started.html
I did the ALL_BUILD on Windows with Visual Studio 2010 and added the built stuff to my system path with $PATH=...ClangSourcBuildPath...\build\bin\Release
I now can compile the following file on the console with:
$> clang file_c.c
//file_c.c
#include <stdio.h>
int main()
{
printf("hello world\n");
return 0;
}
But if I do the same for the following file ($> clang file_cpp.cpp):
//file_cpp.cpp
#include <iostream>
int main()
{
std::cout << "Hello World!";
return 0;
}
I get the following errors:
In file included from file_cpp.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\iostream:9:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\istream:9:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\ostream:9:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\ios:9:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\streambuf:9:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\xlocnum:13:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\xiosbase:9:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\xlocale:11:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\stdexcept:10:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\xstring:9:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\xmemory:15:
C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\utility:81:10:
error: missing 'typename' prior to dependent type name '_It::iterator_category' typedef _It::iterator_category iterator_category;
C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\utility:82:10:
error: missing 'typename' prior to dependent type name '_It::value_type' typedef _It::value_type value_type;
C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\utility:83:10:
error: missing 'typename' prior to dependent type name '_It::distance_type' typedef _It::distance_type distance_type;
C:\Program Files (x86)\Microsoft Visual Studio\VC98\include\utility:224:32:
error: template parameter redefines default argument
template < class _E, class _Tr = char_traits< _E > >
...
I also tried:
$> clang++ file_cpp.cpp
$> clang -x c++ file_cpp.cpp
But I still get the same errors.
Can someone explain me what's wrong?
There are certain flags (I think it was -fms-extensions, not quite sure of the exact option) that are required to get clang to parse the VC++ headers.
The next problem you'll encounter is that the resulting executable cannot be linked. This is due to the fact that clang uses a different name mangling than MSVC, and will result in undefined references.
If you want to use Clang on Windows (which is currently possible with MinGW-w64), you can use my prebuilt packages, you'll need
Clang 3.2
GCC 4.6
Extracted to the same directory. GCC is in this case only used to call the linker. Clang can be used to compile everything.
There is currently no way to use clang for C++ with the Visual Studio headers+libs. C should work, but I haven't tested and there may be other ABI problems preventing this from working.

Visual Studio 2010 and windows SDK 7.0a compilation error

I am new to windows development world. I am having Visual Studio 2010 and windows SDK 7.0a installed on my machine. Any win32 application (even the skeleton generated using the wizard) is giving me this compilation error repeated hundreds of times:
2> Note: including file: C:\Program Files\Microsoft Visual Studio 10.0\VC\include\stdio.h
2> Note: including file: C:\Program Files\Microsoft Visual Studio 10.0\VC\include\crtdefs.h
2> Note: including file: C:\Program Files\Microsoft Visual Studio 10.0\VC\include\swprintf.inl
2> Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Windows.h
2> Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\sdkddkver.h
2> Note: including file: C:\Program Files\Microsoft Visual Studio 10.0\VC\include\excpt.h
2> Note: including file: C:\Program Files\Microsoft Visual Studio 10.0\VC\include\crtdefs.h
2> Note: including file: C:\Program Files\Microsoft Visual Studio 10.0\VC\include\stdarg.h
2> Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\windef.h
2> Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\winnt.h
2> Note: including file: C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ctype.h
2> Note: including file: C:\Program Files\Microsoft Visual Studio 10.0\VC\include\crtdefs.h
2> Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\specstrings.h
*2> Note: including file: c:\program files\microsoft sdks\windows\v7.0a\include\sal_supp.h*
*2> Note: including file: c:\program files\microsoft sdks\windows\v7.0a\include\specstrings_supp.h*
*2> Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\specstrings_strict.h*
*2> Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\specstrings_undef.h*
2> Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\driverspecs.h
*2> Note: including file: c:\program files\microsoft sdks\windows\v7.0a\include\sdv_driverspecs.h*
2>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\driverspecs.h(356): error C3861: 'SAL_functionClass': identifier not found
2>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\driverspecs.h(356): error C2059: syntax error : ')'
2>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\driverspecs.h(374): error C2144: syntax error : 'char' should be preceded by ')'
2>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\driverspecs.h(374): error C3861: 'SAL_acquire': identifier not found
Please advise. Thanks.
Take a look at your VS include paths. If you installed more SDKS (ie, Windows 7.1 or others) then the order may have gotten screwed up. Or perhaps you modified the paths to add some of your own.
Go to Project->Properties->Configuration Properties->VC++ Directories->Include Directories. Mine looks like this:
Include Directories =$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;
I'd suggest making them look like the default and seeing if you still have the problem. You may have to fix your Library Directories if it doesn't link after it compiles. Mine looks like this:
Library Directories =$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib

Release configuration build, debug doesn't

I'm developing an AutoCad plugin (MFC dll), I'm using Visual Studio 2010 and C++.
Until now I was building the project with release configuration (both 32 and 64 bits), with no problems (I've test the plugin inside AutoCad).
But now that I want to debug a function with Visual Studio 2010 just changed the configuration to Debug and the build doesn't succeeded.
The output from build process:
------ Build started: Project: SAM, Configuration: Debug x64 ------
Build started 26/01/2012 11:36:32.
InitializeBuildStatus:
Touching "x64\Debug\SAM.unsuccessfulbuild".
ClCompile:
stdafx.cpp
Note: including file: c:\vs2010_workspace\s\sam\stdafx.h
Note: including file: c:\vs2010_workspace\s\sam\targetver.h
Note: including file: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\SDKDDKVer.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxwin.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afx.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\new.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\sal.h
Note: including file: c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h
c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(27): error C2448: 'message' : function-style initializer appears to be a function definition
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vadefs.h
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vadefs.h(121): error C2065: 'va_list' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vadefs.h(121): error C2059: syntax error : ','
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(486): error C2146: syntax error : missing ';' before identifier 'time_t'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(550): error C2061: syntax error : identifier 'uintptr_t'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(1961): error C2146: syntax error : missing ';' before identifier 'locinfo'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(1961): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(1961): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(1962): error C2146: syntax error : missing ';' before identifier 'mbcinfo'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(1962): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(1962): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(1980): error C2146: syntax error : missing ';' before identifier 'lc_id'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(1980): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(1980): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\new.h(52): error C2143: syntax error : missing ';' before '__cdecl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\new.h(52): error C2065: 'new_handler' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\new.h(52): error C2146: syntax error : missing ')' before identifier '_NewHandler'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\new.h(52): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\new.h(52): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\new.h(52): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\new.h(58): error C2039: 'new_handler' : is not a member of 'std'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\new.h(58): error C2873: 'new_handler' : symbol cannot be used in a using-declaration
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxver_.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxv_w32.h
Note: including file: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winsdkver.h
Note: including file: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\windows.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\excpt.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\stdarg.h
Note: including file: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\windef.h
Note: including file: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(57): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(57): error C2143: syntax error : missing ';' before '*'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(57): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(59): error C2143: syntax error : missing ';' before '*'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(93): error C2061: syntax error : identifier '_locale_t'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(95): error C2061: syntax error : identifier '_locale_t'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(97): error C2061: syntax error : identifier '_locale_t'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(99): error C2061: syntax error : identifier '_locale_t'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(101): error C2061: syntax error : identifier '_locale_t'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(103): error C2061: syntax error : identifier '_locale_t'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(105): error C2061: syntax error : identifier '_locale_t'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(107): error C2061: syntax error : identifier '_locale_t'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(109): error C2061: syntax error : identifier '_locale_t'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(111): error C2061: syntax error : identifier '_locale_t'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(113): error C2061: syntax error : identifier '_locale_t'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(115): error C2061: syntax error : identifier '_locale_t'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(119): error C2061: syntax error : identifier '_locale_t'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(121): error C2061: syntax error : identifier '_locale_t'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(135): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(135): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(135): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(135): error C2491: 'iswalpha' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(135): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(136): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(136): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(136): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(136): error C2491: '_iswalpha_l' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(136): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(137): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(137): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(137): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(137): error C2491: 'iswupper' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(137): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(138): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(138): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(138): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(138): error C2491: '_iswupper_l' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(138): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(139): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(139): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(139): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(139): error C2491: 'iswlower' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(139): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(140): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(140): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(140): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(140): error C2491: '_iswlower_l' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(140): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(141): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(141): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(141): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(141): error C2491: 'iswdigit' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(141): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(142): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(142): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(142): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(142): error C2491: '_iswdigit_l' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(142): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(143): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(143): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(143): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(143): error C2491: 'iswxdigit' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(143): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(144): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(144): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(144): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(144): error C2491: '_iswxdigit_l' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(144): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(145): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(145): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(145): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(145): error C2491: 'iswspace' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(145): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(146): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(146): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(146): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(146): error C2491: '_iswspace_l' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(146): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(147): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(147): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(147): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(147): error C2491: 'iswpunct' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(147): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(148): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(148): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(148): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(148): error C2491: '_iswpunct_l' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(148): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(149): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(149): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(149): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(149): error C2491: 'iswalnum' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(149): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(150): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(150): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(150): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(150): error C2491: '_iswalnum_l' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(150): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(151): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(151): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(151): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(151): error C2491: 'iswprint' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(151): error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(152): error C2065: 'wint_t' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(152): error C2146: syntax error : missing ')' before identifier '_C'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(152): warning C4229: anachronism used : modifiers on data are ignored
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(152): error C2491: '_iswprint_l' : definition of dllimport data not allowed
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(152): fatal error C1003: error count exceeds 100; stopping compilation
Build FAILED.
PS.: I'm not an expert developing whit c++ (I came from Java), I've started just a week ago.
EDIT:
I've commented the piece of code below, and i was able to build. The code was on stdafx.h, and I have no clue of what it mean, someone could explain it to me?
#if defined(_DEBUG) && !defined(_FULLDEBUG_)
#define _DEBUG_WAS_DEFINED
#undef _DEBUG
#pragma
message (" Compiling MFC header files in release mode.")
#endif
You should check your project properties for Debug and for Release configuration and see if you are missing something. I would start with Linker -> Input -> Additional Dependencies and C/C++ -> General -> Additional Include Directories.
I know this answer is a year late, but #pragma and message should be on the same line. Someone probably hit the enter key accidentally. This is why it works in release mode but not debug; _DEBUG is not defined in release configuration.
Visual Studio 2010 has a habit of giving you some weird error messages that should otherwise be straightforward parsing problems.