Stl error with the new visual 2013 community - c++

Just trying the new visual 2013 Community Edition.
My old project does not compile with it.
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\iostream
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\sstream
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\sstream(71): error C2059: syntax error : '('
1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\sstream(370) : see reference to class template instantiation 'std::basic_stringbuf<_Elem,_Traits,_Alloc>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\sstream(71): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\sstream(370): fatal error C1075: end of file found before the left brace '{' at 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\sstream(12)' was matched
This is related to the new platform toolset (v120) when I change to the old v100 (visual 2010) everything compiles just fine.
Any idea ?
Thanks.

Related

Tons of errors in xtr1common when building OpenCV 3.2 in VS2015 Update 3

When building a simple OpenCV app in Visual Studio 2015 Update 3, with OpenCV 3.2, with target x64 (there are no x86 libs in 3.2 release), I get the following errors:
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(100): error C2737: 'std::is_same_v': 'constexpr' object must be initialized
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(100): error C2998: 'const bool std::is_same_v': cannot be a template definition
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(245): error C2737: 'std::is_integral_v': 'constexpr' object must be initialized
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(245): error C2998: 'const bool std::is_integral_v': cannot be a template definition
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(282): error C2737: 'std::is_floating_point_v': 'constexpr' object must be initialized
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(282): error C2998: 'const bool std::is_floating_point_v': cannot be a template definition
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(295): error C2737: 'std::is_arithmetic_v': 'constexpr' object must be initialized
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(295): error C2998: 'const bool std::is_arithmetic_v': cannot be a template definition
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstddef(697): error C2737: 'std::is_function_v': 'constexpr' object must be initialized
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstddef(697): error C2998: 'const bool std::is_function_v': cannot be a template definition
Somehow I dont believe this is a problem with OpenCV, so I guess I am missing something in the build process or have something misconfigured. Any suggestions what should be changed are appreciated :)
I followed the following site http://opencv-srf.blogspot.com/2013/05/installing-configuring-opencv-with-vs.html when it comes to suggestions how to configure VS.
Adding source code, though I believe this is something related to configuration of the build, not to the source code:
#include "opencv2/opencv.hpp"
int main()
{
return 0;
}
I get the same errors when adding OpenCV 3.1 through Nuget as described in OpenCV via NuGet packages with Visual Studio 2015, how to configure? . Interesting enough it looks like similar errors where seen in completely different cases - Visual Studio 2015: C++ REST API (Casablanca) failing compilation in VS inlcudes/headers and where solved by reinstalling VS2015 from RC to full community edition. I am using VS2015 Enterprise Update 3 so I hope is not the root cause...
This problem was apparently caused by issues with VS2015. At least after I did repair of the VS2015 installation (from Program and Features in Windows, the problem is gone)

Compiling moc files Qt 4.5.2 intrin.h unexpected type "void" Visual Studio 2015

I have a project I have been compiling using visual studio 2008 for compatibility reasons. It has been a real pain and am testing compatibility with visual studio 2015. I have custom build steps for several qt object files to run through the MOC and then compile them along with the build. Whenever I try to compile one of the moc files in 2015, I get the following error sequence:
moc_class.cpp
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\intrin.h(200): error C2062: type 'void' unexpected
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\intrin.h(200): error C2144: syntax error: 'void' should be preceded by '('
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\intrin.h(200): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\intrin.h(200): error C2365: '_InterlockedCompareExchange': redefinition; previous definition was 'function'
Any reason why this would occur? I am at a wall and can't seem to find any information on the issue. Using qt 4.5.2.
Qt4 will not work under Visual Studio 2015 unless you build that version (4.5.2) of Qt from source yourself using the Visual Studio 2015.
Another option would be to change your project so that it becomes compatible with Qt5. You can read more about how to do it here: https://wiki.qt.io/Transition_from_Qt_4.x_to_Qt5 .

Compilation errors: Windows API headers.... broken?

I don't know at which point it stopped working, since I've been using Code::Blocks and MinGW for the last month or so. Nonetheless, almost all of my MSVC projects (and new ones as well) have stopped working altogether now that I opened up Visual Studio again, and every time I try to build them I get hundreds of errors in the Windows API headers.
The first and most common (list of many) problems I get is coming from windows.h, after which inclusion I get this:
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winnt.h(3606): warning C4103: 'c:\program files (x86)\microsoft visual studio 10.0\vc\include\winnt.h' : alignment changed after including header, may be due to missing #pragma pack(pop)
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winnt.h(3908): warning C4103: 'c:\program files (x86)\microsoft visual studio 10.0\vc\include\winnt.h' : alignment changed after including header, may be due to missing #pragma pack(pop)
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winnt.h(4006): warning C4068: unknown pragma
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winnt.h(4012): warning C4068: unknown pragma
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winnt.h(4019): warning C4068: unknown pragma
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1482): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1482): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1483): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1483): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1483): error C2086: 'int DECLSPEC_NORETURN' : redefinition
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1482) : see declaration of 'DECLSPEC_NORETURN'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1543): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1543): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1543): error C2086: 'int DECLSPEC_NORETURN' : redefinition
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1482) : see declaration of 'DECLSPEC_NORETURN'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\rpcdce.h(369): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\rpcdce.h(369): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\rpcdce.h(369): error C2086: 'int DECLSPEC_NORETURN' : redefinition
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\winbase.h(1482) : see declaration of 'DECLSPEC_NORETURN'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\rpcdcep.h(89): error C3646: 'I_RpcAllocate' : unknown override specifier
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\rpcdcep.h(89): error C2091: function returns function
...
etc. etc. (full compilation output here)
This is similar, if not the same problem, to some I've found over the web, but still couldn't find any suitable solution out of:
http://www.jenkinssoftware.com/forum/index.php?topic=4877.0;wap2
http://ogre3d.org/forums/viewtopic.php?f=2&t=26302
https://social.msdn.microsoft.com/Forums/vstudio/en-US/0c97c9ed-c6a0-4f35-8bbf-33203e227f68/setting-up-windowsh-not-found?forum=vcgeneral
https://social.msdn.microsoft.com/Forums/vstudio/en-US/6cc0cfe6-2c59-4925-bdda-2920a0f7245b/big-time-problems-with-headers?forum=vclanguage
https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/06ca7ef8-6567-4968-99d3-d989cdcb1b8c/help-errors?forum=vcgeneral
http://irrlicht.sourceforge.net/forum/viewtopic.php?f=1&t=17147
http://forums.codeblocks.org/index.php?topic=4508.0
https://www.c-plusplus.net/forum/167678-full (German link)
https://www.spieleprogrammierer.de/11-hilfe-zum-buch-3d-spieleprogrammierung-von-david-scherfgen/3719-mal-wieder-fehler/ (German link)
https://zakimirza.wordpress.com/2007/03/04/setting-up-sdl-opengl-in-visual-studio/ (in a comment under the article)
It also quite reminds me of the problems I had when (dumbly) trying to compile from MSVC using the MinGW inclusions/libraries some time ago - though everything was still working properly at that point - so the best I can think of, it might be a similar issue, as in the headers became incompatible for some reason. Therefore, I thought, maybe I've installed a Win64 version over them without realizing?
I currently have MS Visual Studio 2010 Express, MS Visual Studio 2013 Express, Code::Blocks (with MinGW) and DevC++ installed. The only thing that changed in this period is that I tried out VS 2010 Ultimate (uninstalled shortly later after the trial expired) to try out some extensions, but everything worked just fine in the meanwhile, I don't know why it suddenly stopped working.
I've tried to uninstall and reinstall MSVC, Windows SDK and the DirectX SDK, but nothing worked. The environmental variables look fine, but maybe I haven't checked properly.
All the projects are in the same working state I've left them in, the environment being Win32 and all the inclusion paths being the same as before.
I really have no clue as what to do!
EDIT:
Both empty projects and simple "Hello World!" programs compile & run correctly. As soon as I #include <windows.h> however, the compilation problems appear.
Solved.
The problem was, the MinGW inclusions somehow ended up in the MSVC directory, making the compiler use those instead. Since they are Unix (POSIX) headers, the MSVC compiler can not compile them, and instead throws an exceptionally long list of errors. To solve this mess, I had to delete all the non-MSVC headers from the inclusion folders. The reason simple uninstall&reinstall didn't work is because MS uninstaller is file-specific and leaves all the non-original files in the directory. Visual Studio doesn't have, in fact, any Windows API header in the inclusion folder, and should be using the ones coming with Windows SDK.
So, since I've seen many people with this problem but no solutions to it, I'll leave the simplest answer here:
In order to clean up the folder from anything not needed, you have to uninstall everything first, then manually delete those folders, and finally reinstall everything. There might be more subtle solutions that would be better if you have many additional libraries installed (I had, in fact, some) and want to delete only the specific faulting headers, leaving the rest, but I don't really know how. If anybody knows of someway to do that, like maybe a tool that checks for MSVC-compatible headers and libraries, please let me know!
EDIT:
Additionally it may occur (at least in my case happened) that the VS SP1 gets also corrupted in the process, thus leading to compiler errors such as:
LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
To solve this, refer to the solutions given in this question.

VS2010 compile errors. stdio.h(378): fatal error C1003: error count exceeds 100; stopping compilation

I uses the win7 x64 OS and VS2010. I encountered an error that looks like something gone wrong with the compiler or setting environments or something like that. It happened during my programming suddenly. At first, my program can be compiled successfully. Then, without any reason(or some reason I didn't realize) the program came out with a long list of errors mentioning "stdio.h"
Then I built a new project for test which is a win32 console application, I followed the default "new->project" procedure and the code is like this:
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
This is the default code(named "test.cpp"). Then I compiled it, and the same list of errors came out. They are like follows:
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(238): error C2061: 语法错误: 标识符“_Printf_format_String_”
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(240): error C2061: 语法错误: 标识符“_Printf_format_String_”
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(253): error C2061: 语法错误: 标识符“_Scanf_format_String_”
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(254): error C2061: 语法错误: 标识符“_Scanf_format_String_”
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(258): error C2061: 语法错误: 标识符“_Scanf_s_format_String_”
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(260): error C2061: 语法错误: 标识符“_Scanf_s_format_String_”
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(285): error C2065: “_Printf_format_String_”: 未声明的标识符
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(285): error C2143: 语法错误 : 缺少“)”(在“const”的前面)
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(285): warning C4229: 使用了记时错误: 忽略数据上的修饰符
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(285): error C2491: “printf”: 不允许 dllimport 数据 的定义
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(285): error C2059: 语法错误:“)”
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(287): error C2065: “_Printf_format_String_”: 未声明的标识符
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(287): error C2143: 语法错误 : 缺少“)”(在“const”的前面)
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(287): warning C4229: 使用了记时错误: 忽略数据上的修饰符
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(287): error C2491: “printf_s”: 不允许 dllimport 数据 的定义
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(287): error C2059: 语法错误:“)”
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(304): error C2065: “_Scanf_format_String_”: 未声明的标识符
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(304): error C2143: 语法错误 : 缺少“)”(在“const”的前面)
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(304): warning C4229: 使用了记时错误: 忽略数据上的修饰符
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(304): error C2491: “scanf”: 不允许 dllimport 数据 的定义
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(304): error C2059: 语法错误:“)”
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(305): error C2065: “_Scanf_format_String_”: 未声明的标识符
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(305): error C2143: 语法错误 : 缺少“)”(在“const”的前面)
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(305): warning C4229: 使用了记时错误: 忽略数据上的修饰符
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(305): error C2491: “_scanf_l”: 不允许 dllimport 数据 的定义
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(305): error C2059: 语法错误:“)”
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(309): error C2065: “_Scanf_s_format_String_”: 未声明的标识符
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(309): error C2143: 语法错误 : 缺少“)”(在“const”的前面)
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(309): warning C4229: 使用了记时错误: 忽略数据上的修饰符
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(309): error C2491: “scanf_s”: 不允许 dllimport 数据 的定义
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(309): error C2059: 语法错误:“)”
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(311): error C2065: “_Scanf_s_format_String_”: 未声明的标识符
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(311): error C2143: 语法错误 : 缺少“)”(在“const”的前面)
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(311): warning C4229: 使用了记时错误: 忽略数据上的修饰符
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(311): error C2491: “_scanf_s_l”: 不允许 dllimport 数据 的定义
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(311): error C2059: 语法错误:“)”
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(318): error C2061: 语法错误: 标识符“_Printf_format_String_”
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(319): error C2065: “_Dest”: 未声明的标识符
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(319): error C2275: “size_t”: 将此类型用作表达式非法
...
...
c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(378): fatal error C1003: error count exceeds 100; stopping compilation
I have tried to restart the VS2010 and restart the computer, but it didn't help. It's driving me crazy, can any body help? Thanks!
The "stdafx.h" is like this:
// stdafx.h : 标准系统包含文件的包含文件,
// 或是经常使用但不常更改的
// 特定于项目的包含文件
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: 在此处引用程序需要的其他头文件
What happens if exclude <stdio.h>? Maybe you accidentally edited this file. What is the date of the stdio.h?
You can try get etalon stdio.h and compare files (with WinMerge utility or similar). Meanwhile C++ programs can work without it, <iostream> will be enough.

VS 2010 Build error

I am compiling a executable Win32 console application in 2010 which was developed in VS 2005. I have checked all the settings with VS 2005, still it throws following Build Error. Please help.
1>------ Rebuild All started: Project: vssreg, Configuration: Debug x64 ------
1> stdafx.cpp
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(543): error C2065: '_In_opt_z_' : undeclared identifier
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(543): error C2143: syntax error : missing ')' before 'const'
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(543): warning C4229: anachronism used : modifiers on data are ignored
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(543): error C2182: '_invalid_parameter' : illegal use of type 'void'
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(543): error C2491: '_invalid_parameter' : definition of dllimport data not allowed
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(543): error C2059: syntax error : ')'
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(550): error C2065: '_In_opt_z_' : undeclared identifier
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(550): error C2143: syntax error : missing ')' before 'const'
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(550): warning C4229: anachronism used : modifiers on data are ignored
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(550): error C2182: '_invoke_watson' : illegal use of type 'void'
When I tried to put /ShowIncludes option , im getting following includes info
1>------ Rebuild All started: Project: vssreg, Configuration: Debug x64 ------
1> stdafx.cpp
1> Note: including file: c:\rajesh\hak\hak27x64\2010\hak_27_x64\itxvssreg\stdafx.h
1> Note: including file: c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\iostream
1> Note: including file: c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\istream
1> Note: including file: c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ostream
1> Note: including file: c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ios
1> Note: including file: c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xlocnum
1> Note: including file: c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\climits
1> Note: including file: c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\yvals.h
1> Note: including file: c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdefs.h
1> Note: including file: C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\sal.h
1> Note: including file: c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vadefs.h
This line from your show includes is a bit of a giveaway
C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\sal.h
Somehow you are still including a VS 2005 header. As a first step I would try renaming the v6.1 directory see if that fixes the problem. If that's it then look to your project settings so that C:\Program Files\Microsoft SDKs is not referenced.
Also (in addition to checking Includes, on VC++ Directories and C++\General), try to change Platform Toolset in project properties.
Check registry keys with SDK registration. Yes, example is for Windows v7.1.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows]
"CurrentInstallFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\"
"ProductVersion"="v7.1"
[HKEY_CURRENT_USER\Software\Microsoft\Microsoft SDKs\Windows]
"CurrentInstallFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\"
"CurrentVersion"="v7.1"