VS 2010 Build error - c++

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"

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)

Stl error with the new visual 2013 community

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.

How to create a mixed mode CLR .NET DLL that uses AFX libraries?

I am trying to create a mixed mode (managed and unmanaged) C++ DLL with CLR option and I require the use of AFX library. So I included "afxwin.h" in a file (which uses GL/gl.h).
However I run into compile errors no matter what I do and I have tried every option in the project settings to fix them, but no use.
A. When I compile with CLR option I see this error (when it compiles the file which includes afwin.h):
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afx.h(24): fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
B. When I compile with _AFXDLL defined in stdafx.cpp or enabling "Use MFC in a shared DLL", to address the error in A, I see these and whole bunch of other errors in the same file:
1> _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxanimationcontroller.h(46): error C2059: syntax error : '-'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxanimationcontroller.h(60): error C2143: syntax error : missing ';' before '}'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxanimationcontroller.h(60): error C2238: unexpected token(s) preceding ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxanimationcontroller.h(61): error C2059: syntax error : 'public'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxanimationcontroller.h(65): error C2059: syntax error : ')'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxanimationcontroller.h(65): error C2589: '-' : illegal token on right side of '::'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxanimationcontroller.h(65): error C2059: syntax error : '::'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afxanimationcontroller.h(67): error C2143: syntax error : missing ';' before '{'
Any ideas on how to fix this issue? I am using VS 2010.
Changing the MFC option afterwards to "Use MFC in a shared DLL" is not that straightforward, there are other options you may need to change.
The easiest way is to create a new dummy MFC project with the wizard and compare the project properties of the two projects.
Re CLR, what works for me is to place all managed C++ code in one or two sources and turn on /CLR only for those sources instead of the whole project.

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.

C++: Compilation of translation units independence and old winsock2.h types redefinition error [duplicate]

This question already has answers here:
C++ Redefinition Header Files (winsock2.h)
(15 answers)
Closed 6 years ago.
As far as I know translation units no nothing about each other on the compilation phase. Can you explain why do I have then that strange behavior: after include windows.h in one A.cpp (which actually doesn't use socket api and doesn't include winsock2.h) I get error while compiling ANOTHER B.cpp with winsock2.h winsock.h conflict. This B.cpp hasn't been changed at all. Thanks in advance.
EDIT: It's actually a COMPILATION not link error. I've put msvc compiler in a verbose mode here header include tree:
2>perfomancemeter.cpp
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\numeric
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\iterator
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\xutility
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\climits
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\yvals.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\crtdefs.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\sal.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\crtassem.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\vadefs.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\use_ansi.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\limits.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\crtdefs.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\utility
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\iosfwd
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\cstdio
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\stdio.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\crtdefs.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\swprintf.inl
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\cstring
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\string.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\crtdefs.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\cwchar
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\wchar.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\crtdefs.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\wtime.inl
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\xstddef
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\cstddef
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\stddef.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\crtdefs.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\crtdbg.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\crtdefs.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\algorithm
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\memory
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\xmemory
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\cstdlib
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\stdlib.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\crtdefs.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\exception
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\eh.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\crtdefs.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\malloc.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\crtdefs.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\new
2>Note: including file: d:\repos\cbs\billing\common\perfomancemeter.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\vector
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\stdexcept
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\xstring
2>Note: including file: d:\repos\cbs\billing\common\util.h
2>Note: including file: d:\repos\cbs\billing\common\framework\include\types/types.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\string
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\istream
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\ostream
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\ios
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\xlocnum
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\streambuf
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\xiosbase
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\xlocale
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\typeinfo
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\xdebug
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\xlocinfo
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\xlocinfo.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\ctype.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\crtdefs.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\locale.h
2>Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\crtdefs.h
1>c:\program files (x86)\microsoft visual studio 8\vc\platformsdk\include\winsock2.h(112) : error C2011: 'fd_set' : 'struct' type redefinition
1> c:\program files (x86)\microsoft visual studio 8\vc\platformsdk\include\winsock.h(54) : see declaration of 'fd_set'
I faced this problem before and know that
#define WIN32_LEAN_AND_MEAN
before including windows header fixes it. But why is it happening in this case?
Windows.h includes winsock. So even if you do not include directly and do not use it, it will get included. #define WIN32_LEAN_AND_MEAN resolves this problem because this forces inclusion of only necessary headers.
Possibilities:
You have somehow ended up including winsock/winsock2 twice: Try removing winsock direct include and include only windows.h
You have added windows/winsock to a common header file: Check the include hierarchy. For testing remove common headers and try to include them directly in the source files
Do you have pre-compiled headers turned on? Try turning it off
See this for reference: http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/6177f9bc-db75-4317-9904-02ef55b527d0