I am trying to include the xact3.h header file in a game project but i keep getting some errors related to mmreg.h
#include <xact3.h>
#include <Windows.h>
1>c:\program files\windows kits\8.0\include\shared\mmreg.h(2469): error C2332: 'struct' : missing tag name
1>c:\program files\windows kits\8.0\include\shared\mmreg.h(2469): warning C4094: untagged 'struct' declared no symbols
1>c:\program files\windows kits\8.0\include\shared\mmreg.h(2469): error C2143: syntax error : missing ';' before '__uuidof'
1>c:\program files\windows kits\8.0\include\shared\mmreg.h(2469): error C2059: syntax error : '__uuidof'
1>c:\program files\windows kits\8.0\include\shared\mmreg.h(2470): warning C4005: 'KSDATAFORMAT_SUBTYPE_PCM' : macro redefinition
Those above are some of the errors i get. I am using Windows 8 if that is relevant. I've tried a lot of things like defining WIN32_LEAN_AND_MEAN or rearanging the headers but without success. Can someone tell me what could be the problem and how can I fix it?
Managed to solve it by adding the XAudio2 header above the xact3 header
Related
I have created my own directory "cpplibs" for storing my library code and the files are there. For whatever reason the "portaudio.sln" file isn't able to properly link to my files. How do I organize my files so that everything gets to the right place, and I don't get any "undefined identifier" or similar errors?
Here is the specific output I am receiving. I did some research or defining directories but still ran into some issues.
1>------ Build started: Project: portaudio, Configuration: Debug Win32 ------
1>C:\Program Files (x86)\for visual studio\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(944,5): warning MSB8027: Two or more files with the name of asio.cpp will produce outputs to the same location. This can lead to an incorrect build result. The files involved are ..\..\..\ASIOSDK2.3.2\common\asio.cpp, ..\..\src\hostapi\asio\ASIOSDK\common\asio.cpp.
1>C:\Program Files (x86)\for visual studio\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(944,5): warning MSB8027: Two or more files with the name of asiodrivers.cpp will produce outputs to the same location. This can lead to an incorrect build result. The files involved are ..\..\..\ASIOSDK2.3.2\host\asiodrivers.cpp, ..\..\src\hostapi\asio\ASIOSDK\host\asiodrivers.cpp.
1>C:\Program Files (x86)\for visual studio\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(944,5): warning MSB8027: Two or more files with the name of asiolist.cpp will produce outputs to the same location. This can lead to an incorrect build result. The files involved are ..\..\..\ASIOSDK2.3.2\host\pc\asiolist.cpp, ..\..\src\hostapi\asio\ASIOSDK\host\pc\asiolist.cpp.
1>cl : Command line warning D9035: option 'Gm' has been deprecated and will be removed in a future release
1>hostsample.cpp
1>c:\program files\cpplibs\asiosdk2.3.2\host\sample\hostsample.cpp(13): fatal error C1083: Cannot open include file: 'asiosys.h': No such file or directory
1>asiolist.cpp
1>c:\program files\cpplibs\asiosdk2.3.2\host\pc\asiolist.cpp(2): fatal error C1083: Cannot open include file: 'iasiodrv.h': No such file or directory
1>asiodrivers.cpp
1>c:\program files\cpplibs\asiosdk2.3.2\host\asiodrivers.h(13): fatal error C1083: Cannot open include file: 'asiolist.h': No such file or directory
1>asiodrvr.cpp
1>c:\program files\cpplibs\asiosdk2.3.2\common\asiodrvr.cpp(16): fatal error C1189: #error: do not use this
1>asio.cpp
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): error C2011: 'IASIO': 'struct' type redefinition
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asiodrvr.h(26): error C2504: 'IASIO': base class undefined
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(79): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(81): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(87): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(88): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(76): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\string.h(119): note: see declaration of 'strcpy'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(86): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\string.h(119): note: see declaration of 'strcpy'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(101): error C2039: 'removeCurrentDriver': is not a member of 'AsioDriver'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asiodrvr.h(26): note: see declaration of 'AsioDriver'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(114): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(121): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(131): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(141): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(151): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(158): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(165): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(172): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(182): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(189): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(196): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(208): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(205): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\string.h(119): note: see declaration of 'strcpy'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(221): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(228): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(235): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(242): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\asio.cpp(249): error C2027: use of undefined type 'IASIO'
1>c:\program files\cpplibs\asiosdk2.3.2\common\iasiodrv.h(11): note: see declaration of 'IASIO'
1>Generating Code...
1>Done building project "portaudio.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Here's how you can build portaudio from a command line:
git clone https://git.assembla.com/portaudio.git
cd portaudio
cmake -S .
msbuild portaudio.sln /m /p:Configuration=Release
Your output is in Release directory.
You can download the utilities from:
git - https://git-scm.com/download/win
cmake - https://cmake.org/download/
msbuild - just run 'Developer Command Prompt' from Windows Start menu
Are you using git in your project ?
I had the same problem and when i removed git from the directory it worked well.
I am trying to compile a small piece of C++ code with Visual Studio 2015,and when I include iostream library,I get some weird compile errors,Can anyone help me solve it ?
Here is my code
#include "stdafx.h"
#include <iostream>
int main()
{
std::cout << "Somethig" << std::endl;
return 0;
}
And here are the errors I get when I compile this
1>------ Build started: Project: ConsoleApplication3, Configuration: Debug Win32 ------
1> stdafx.cpp
1> ConsoleApplication3.cpp
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
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(524): error C2275: '_To': illegal use of this type as an expression
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(521): note: see declaration of '_To'
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(526): note: see reference to class template instantiation 'std::is_assignable<_To,_From>' being compiled
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(524): error C2275: '_From': illegal use of this type as an expression
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(522): note: see declaration of '_From'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(524): error C3861: '__is_assignable': identifier not found
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(524): error C2975: '_Val': invalid template argument for 'std::integral_constant', expected compile-time constant expression
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\xtr1common(21): note: see declaration of '_Val'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(1245): error C2061: syntax error: identifier '__make_integer_seq'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(1249): error C2065: '_Vals': undeclared identifier
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(1249): error C2975: '_Vals': invalid template argument for 'std::integer_sequence', expected compile-time constant expression
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(1190): note: see declaration of '_Vals'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(1252): error C2061: syntax error: identifier 'make_integer_sequence'
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\type_traits(1261): error C2631: 'identity': a class or enum cannot be defined in an alias template
1>c:\users\ugurku\documents\visual studio 2015\projects\consoleapplication3\consoleapplication3\stdafx.cpp : fatal error C1903: unable to recover from previous error(s); stopping compilation
1> INTERNAL COMPILER ERROR in 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe'
1> Please choose the Technical Support command on the Visual C++
1> Help menu, or open the Technical Support help file for more information
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
All helps will be appriciated.
Seems like it was a problem about my Visual Studio installation,I just reinstalled it and the problem is gone.
#include <cstdlib>
You should reinstall the visual studios because the only thing I think of why you code wouldn't compile would be is because you forget the library header
Errors:
1>------ Build started: Project: alglibTest, Configuration: Debug Win32 ------
1>Build started 5/22/2011 12:52:26 PM.
1>InitializeBuildStatus:
1> Touching "Debug\alglibTest.unsuccessfulbuild".
1>ClCompile:
1> main.cpp
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(38): error C2054: expected '(' to follow 'using'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(40): error C2061: syntax error : identifier 'using'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(40): error C2054: expected '(' to follow 'using'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(40): error C2061: syntax error : identifier 'using'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(41): error C2061: syntax error : identifier 'clearerr'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(41): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(41): error C2061: syntax error : identifier 'fclose'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(41): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(41): error C2061: syntax error : identifier 'feof'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(41): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(42): error C2061: syntax error : identifier 'ferror'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(42): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(42): error C2061: syntax error : identifier 'fflush'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(42): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(42): error C2061: syntax error : identifier 'fgetc'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(42): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(43): error C2061: syntax error : identifier 'fgetpos'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(43): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(43): error C2061: syntax error : identifier 'fgets'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(43): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(43): error C2061: syntax error : identifier 'fopen'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(43): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(44): error C2061: syntax error : identifier 'fprintf'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(44): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(44): error C2061: syntax error : identifier 'fputc'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(44): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(44): error C2061: syntax error : identifier 'fputs'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(44): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(45): error C2061: syntax error : identifier 'fread'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(45): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(45): error C2061: syntax error : identifier 'freopen'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(45): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(45): error C2061: syntax error : identifier 'fscanf'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(45): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(46): error C2061: syntax error : identifier 'fseek'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(46): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(46): error C2061: syntax error : identifier 'fsetpos'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(46): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(46): error C2061: syntax error : identifier 'ftell'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(46): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(47): error C2061: syntax error : identifier 'fwrite'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(47): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(47): error C2061: syntax error : identifier 'getc'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(47): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(47): error C2061: syntax error : identifier 'getchar'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(47): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(48): error C2061: syntax error : identifier 'gets'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(48): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(48): error C2061: syntax error : identifier 'perror'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(48): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(49): error C2061: syntax error : identifier 'putc'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(49): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(49): error C2061: syntax error : identifier 'putchar'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(49): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(50): error C2061: syntax error : identifier 'printf'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(50): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(50): error C2061: syntax error : identifier 'puts'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(50): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(50): error C2061: syntax error : identifier 'remove'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(50): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(51): error C2061: syntax error : identifier 'rename'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(51): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(51): error C2061: syntax error : identifier 'rewind'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(51): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(51): error C2061: syntax error : identifier 'scanf'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(51): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(52): error C2061: syntax error : identifier 'setbuf'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(52): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(52): error C2061: syntax error : identifier 'setvbuf'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(52): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(52): error C2061: syntax error : identifier 'sprintf'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(52): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(53): error C2061: syntax error : identifier 'sscanf'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(53): error C2059: syntax error : ';'
1 >c:\program files\microsoft visual studio 10.0\vc\include\cstdio(53): error C2061: syntax error : identifier 'tmpfile'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(53): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(53): error C2061: syntax error : identifier 'tmpnam'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(53): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(54): error C2061: syntax error : identifier 'ungetc'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(54): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(54): error C2061: syntax error : identifier 'vfprintf'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(54): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(54): error C2061: syntax error : identifier 'vprintf'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(54): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(55): error C2061: syntax error : identifier 'vsprintf'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdio(55): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(19): error C2054: expected '(' to follow 'using'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(19): error C2061: syntax error : identifier 'using'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(19): error C2054: expected '(' to follow 'using'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(21): error C2061: syntax error : identifier 'using'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(21): error C2061: syntax error : identifier 'abs'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(21): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(21): error C2061: syntax error : identifier 'atexit'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(21): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(22): error C2061: syntax error : identifier 'atof'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(22): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(22): error C2061: syntax error : identifier 'atoi'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(22): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(22): error C2061: syntax error : identifier 'atol'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(22): error C2059: syntax error : ';'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(23): error C2061: syntax error : identifier 'bsearch'
1>c:\program files\microsoft visual studio 10.0\vc\include\cstdlib(23): fatal error C1003: error count exceeds 100; stopping compilation
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.57
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
What can I do about it?
This usually happens when you are trying to compile C code with C++ headers. If you want to compile C code, change C++ headers to C headers (cstdio to stdio.h, cstdlib to stdlib.h), if you want to compile C++ code, change your project settings (Configuration Properties -> C/C++ -> Advanced -> Compile As C++ code).
I got
error C2894: templates cannot be declared to have 'C' linkage
when i try to compile my C++ project.
all error point me to vc++ files
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(32): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(120): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(133): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(256): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(279): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(375): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(474): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(486): error C2039: 'memcmp' : is not a member of '`global namespace''
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(486): error C3861: 'memcmp': identifier not found
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(491): error C2039: 'strlen' : is not a member of '`global namespace''
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(491): error C3861: 'strlen': identifier not found
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(511): error C2039: 'memchr' : is not a member of '`global namespace''
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(511): error C3861: 'memchr': identifier not found
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(522): error C2039: 'memset' : is not a member of '`global namespace''
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(522): error C3861: 'memset': identifier not found
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(568): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(571): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(574): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(577): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(580): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(583): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(586): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(589): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(592): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(596): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(600): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(604): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(608): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(611): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(614): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(617): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(622): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(625): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\iosfwd(628): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\limits(80): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\limits(133): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\limits(139): error C2894: templates cannot be declared to have 'C' linkage
1>c:\program files\microsoft visual studio 10.0\vc\include\limits(139): fatal error C1003: error count exceeds 100; stopping compilation
what are these errors and how i can solve them.'
these errors appear suddenly while before i never see these errors.
in the project i am working on, i never use extern C
thanks
This error happens when you include your header file inside extern "C" command
extern "C"
{
#include "Header.h"
}
just include #include "cs.h" outside extern c and you are good to go.
#include "Header.h"
extern "C"
{
//code
}
It's hard to provide any help for you without showing your sources but info on MSDN for error #2894 and on some other portals is pretty straight forward:
// C2894.cpp
extern "C" {
template<class T> class stack {}; // C2894 fail
template<class T> void f(const T &aT) {} // C2894
}
Maybe you have file named .c instead of .cpp, or switched some compilation flags.
if you have written this...
extern "C"
{
#include "Header.h"
}
than write it as
extern "C++"
{
#include "Header.h"
}
When you try to refer a C functions in C++ it will through error to avoid that you just quote it to C++ so that you can refer it in .CXX or .Cpp functions
Sometimes the reason is very simple: some file name(s) in your project are the same as in standard C/C++ library that is included in your project by default settings of VS.
For example, string.h. And this fact will spawn the error. Just rename such files and you will get success in building your project.
I cannot include WinSock2.h in a msvc++2010 project. At first I though it was something I was doing wrong, so I created an empty project to test my sanity. The empty project is as follows
#include <Windows.h>
#include <WinSock2.h>
int main(void){
system("echo Hello World");
system("pause");
return 0;
};
It compiles and works fine without the line #include <WinSock2.h> but it fails with a long list of errors when I do try and include WinSock2.h.
Errors:
1> Main.cpp
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(91): warning C4005: 'AF_IPX' : macro redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(460) : see previous definition of 'AF_IPX'
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(131): warning C4005: 'AF_MAX' : macro redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(479) : see previous definition of 'AF_MAX'
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(168): warning C4005: 'SO_DONTLINGER' : macro redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(402) : see previous definition of 'SO_DONTLINGER'
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(212): error C2011: 'sockaddr' : 'struct' type redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(485) : see declaration of 'sockaddr'
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(390): error C2059: syntax error : 'constant'
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(390): error C3805: 'constant': unexpected token, expected either '}' or a ','
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(524): warning C4005: 'IN_CLASSA' : macro redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(287) : see previous definition of 'IN_CLASSA'
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(530): warning C4005: 'IN_CLASSB' : macro redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(293) : see previous definition of 'IN_CLASSB'
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(536): warning C4005: 'IN_CLASSC' : macro redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(299) : see previous definition of 'IN_CLASSC'
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(547): warning C4005: 'INADDR_ANY' : macro redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(304) : see previous definition of 'INADDR_ANY'
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(549): warning C4005: 'INADDR_BROADCAST' : macro redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(306) : see previous definition of 'INADDR_BROADCAST'
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(583): error C2011: 'sockaddr_in' : 'struct' type redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(312) : see declaration of 'sockaddr_in'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(132): error C2011: 'fd_set' : 'struct' type redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(68) : see declaration of 'fd_set'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(167): warning C4005: 'FD_SET' : macro redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(102) : see previous definition of 'FD_SET'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(176): error C2011: 'timeval' : 'struct' type redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(111) : see declaration of 'timeval'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(232): error C2011: 'hostent' : 'struct' type redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(167) : see declaration of 'hostent'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(245): error C2011: 'netent' : 'struct' type redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(180) : see declaration of 'netent'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(252): error C2011: 'servent' : 'struct' type redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(187) : see declaration of 'servent'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(264): error C2011: 'protoent' : 'struct' type redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(199) : see declaration of 'protoent'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(360): error C2011: 'WSAData' : 'struct' type redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(322) : see declaration of 'WSAData'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(458): error C2011: 'sockproto' : 'struct' type redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(494) : see declaration of 'sockproto'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(500): error C2011: 'linger' : 'struct' type redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(531) : see declaration of 'linger'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(513): warning C4005: 'SOMAXCONN' : macro redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(544) : see previous definition of 'SOMAXCONN'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(542): warning C4005: 'FD_READ' : macro redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(562) : see previous definition of 'FD_READ'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(545): warning C4005: 'FD_WRITE' : macro redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(563) : see previous definition of 'FD_WRITE'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(548): warning C4005: 'FD_OOB' : macro redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(564) : see previous definition of 'FD_OOB'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(551): warning C4005: 'FD_ACCEPT' : macro redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(565) : see previous definition of 'FD_ACCEPT'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(554): warning C4005: 'FD_CONNECT' : macro redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(566) : see previous definition of 'FD_CONNECT'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(557): warning C4005: 'FD_CLOSE' : macro redefinition
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(567) : see previous definition of 'FD_CLOSE'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1578): error C2375: 'accept' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(742) : see declaration of 'accept'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1600): error C2375: 'bind' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(747) : see declaration of 'bind'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1619): error C2375: 'closesocket' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(752) : see declaration of 'closesocket'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1638): error C2375: 'connect' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(754) : see declaration of 'connect'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1659): error C2375: 'ioctlsocket' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(759) : see declaration of 'ioctlsocket'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1680): error C2375: 'getpeername' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(764) : see declaration of 'getpeername'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1701): error C2375: 'getsockname' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(769) : see declaration of 'getsockname'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1724): error C2375: 'getsockopt' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(774) : see declaration of 'getsockopt'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1745): error C2375: 'htonl' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(781) : see declaration of 'htonl'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1762): error C2375: 'htons' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(783) : see declaration of 'htons'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1780): error C2375: 'inet_addr' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(785) : see declaration of 'inet_addr'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1797): error C2375: 'inet_ntoa' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(787) : see declaration of 'inet_ntoa'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1815): error C2375: 'listen' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(789) : see declaration of 'listen'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1833): error C2375: 'ntohl' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(793) : see declaration of 'ntohl'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1850): error C2375: 'ntohs' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(795) : see declaration of 'ntohs'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1870): error C2375: 'recv' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(797) : see declaration of 'recv'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1895): error C2375: 'recvfrom' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(803) : see declaration of 'recvfrom'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1921): error C2375: 'select' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(811) : see declaration of 'select'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1945): error C2375: 'send' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(818) : see declaration of 'send'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1970): error C2375: 'sendto' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(824) : see declaration of 'sendto'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(1996): error C2375: 'setsockopt' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(832) : see declaration of 'setsockopt'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2018): error C2375: 'shutdown' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(839) : see declaration of 'shutdown'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2039): error C2375: 'socket' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(843) : see declaration of 'socket'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2063): error C2375: 'gethostbyaddr' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(850) : see declaration of 'gethostbyaddr'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2083): error C2375: 'gethostbyname' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(855) : see declaration of 'gethostbyname'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2101): error C2375: 'gethostname' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(857) : see declaration of 'gethostname'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2121): error C2375: 'getservbyport' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(861) : see declaration of 'getservbyport'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2141): error C2375: 'getservbyname' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(865) : see declaration of 'getservbyname'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2160): error C2375: 'getprotobynumber' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(869) : see declaration of 'getprotobynumber'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2178): error C2375: 'getprotobyname' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(871) : see declaration of 'getprotobyname'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2200): error C2375: 'WSAStartup' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(875) : see declaration of 'WSAStartup'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2219): error C2375: 'WSACleanup' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(879) : see declaration of 'WSACleanup'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2236): error C2375: 'WSASetLastError' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(881) : see declaration of 'WSASetLastError'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2253): error C2375: 'WSAGetLastError' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(883) : see declaration of 'WSAGetLastError'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2270): error C2375: 'WSAIsBlocking' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(885) : see declaration of 'WSAIsBlocking'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2287): error C2375: 'WSAUnhookBlockingHook' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(887) : see declaration of 'WSAUnhookBlockingHook'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2304): error C2375: 'WSASetBlockingHook' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(889) : see declaration of 'WSASetBlockingHook'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2321): error C2375: 'WSACancelBlockingCall' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(891) : see declaration of 'WSACancelBlockingCall'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2343): error C2375: 'WSAAsyncGetServByName' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(893) : see declaration of 'WSAAsyncGetServByName'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2370): error C2375: 'WSAAsyncGetServByPort' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(901) : see declaration of 'WSAAsyncGetServByPort'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2396): error C2375: 'WSAAsyncGetProtoByName' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(909) : see declaration of 'WSAAsyncGetProtoByName'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2421): error C2375: 'WSAAsyncGetProtoByNumber' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(916) : see declaration of 'WSAAsyncGetProtoByNumber'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2446): error C2375: 'WSAAsyncGetHostByName' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(923) : see declaration of 'WSAAsyncGetHostByName'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2473): error C2375: 'WSAAsyncGetHostByAddr' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(930) : see declaration of 'WSAAsyncGetHostByAddr'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2496): error C2375: 'WSACancelAsyncRequest' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(939) : see declaration of 'WSACancelAsyncRequest'
1>c:\program files\microsoft sdks\windows\v7.0a\include\winsock2.h(2517): error C2375: 'WSAAsyncSelect' : redefinition; different linkage
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(941) : see declaration of 'WSAAsyncSelect'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I am assuming that Microsoft would not distribute bad header files in their SDK, what's going on?
I believe you are getting these errors because windows.h will include winsock.h. Reverse the order of your includes so that WinSock2.h comes before windows.h. WinSock2.h has some #defines in it to keep windows.h from including winsock.h
I made sure that an #include "Winsock2.h" is before any #include "windows.h" and "#include "Winsock.h" and this solved the case.
Just a matter of patience, look at includes one by one and establish this order, first #include "Winsock2.h" then #include "windows.h"
I checked the recursive includes, I spotted the header files which include (recursively) some #include "windows.h" and "#include "Winsock.h"and write a#include "Winsock2.h". in this files, i added#include "Winsock2.h"` as the first include.