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.
Related
I have a very simple program that I am trying to compile before I build it out any further. I am trying to learn COM so following along here, I create app.h and app.cpp file in VS 2017 and using the ATL Template. When I try to build the solution I get a lot of MIDL 200 redefinition errors.
UPDATE (Based on #Roman R.'s response) Note that if I used cl /LD app.cpp on a Dev Command Line, I am able to generate app.dll correctly. The MIDL 2003 redefinition errors show up only when trying to build the solution through Visual Studio. I am working with VS 2017 Community edition, so not sure if other versions of Visual Studio have the same problem.
My Include path is simply inherited from the parent defaults i.e. the standard $(VC_IncludePath) and $(WindowsSDK_IncludePath). My Windows SDK version is 10.0.17763.0 and MSVC version is 14.16.27023
//app.h
#pragma once
#define STRICT
#ifndef _WINVER
#define _WINVER 0x0A00
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0A00
#endif
#define _USRDLL
#define _ATL_ATTRIBUTES
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#include <SDKDDKVer.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
using namespace ATL;
//app.cpp
#include "app.h"
[module(dll, name = "app", helpstring = "APP 1.0 Type Library")];
[emitidl];
When I try to build the solution, I get a lot of MIDL2003 errors; snippet from Debug\app.log below:
Microsoft (R) 32b/64b MIDL Compiler Version 8.01.0622
Copyright (c) Microsoft Corporation. All rights reserved.
Processing .\vc140.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared\wtypes.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared\wtypesbase.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared\basetsd.h
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared\guiddef.h
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\wincrypt.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\prsht.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\objidl.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\unknwn.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\propidlbase.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\oaidl.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\urlmon.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\oleidl.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\servprov.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\msxml.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\propidl.idl
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(56): error MIDL2003: redefinition : tagVersionedStream
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(60): error MIDL2003: redefinition : PROPSETFLAG_DEFAULT
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(61): error MIDL2003: redefinition : PROPSETFLAG_NONSIMPLE
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(62): error MIDL2003: redefinition : PROPSETFLAG_ANSI
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(64): error MIDL2003: redefinition : PROPSETFLAG_UNBUFFERED
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(66): error MIDL2003: redefinition : PROPSETFLAG_CASE_SENSITIVE
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(70): error MIDL2003: redefinition : PROPSET_BEHAVIOR_CASE_SENSITIVE
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(90): error MIDL2003: redefinition : tagCAC
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(91): error MIDL2003: redefinition : tagCAUB
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(92): error MIDL2003: redefinition : tagCAI
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(93): error MIDL2003: redefinition : tagCAUI
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(94): error MIDL2003: redefinition : tagCAL
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(95): error MIDL2003: redefinition : tagCAUL
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(96): error MIDL2003: redefinition : tagCAFLT
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(97): error MIDL2003: redefinition : tagCADBL
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(98): error MIDL2003: redefinition : tagCACY
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(99): error MIDL2003: redefinition : tagCADATE
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(100): error MIDL2003: redefinition : tagCABSTR
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(101): error MIDL2003: redefinition : tagCABSTRBLOB
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(102): error MIDL2003: redefinition : tagCABOOL
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(103): error MIDL2003: redefinition : tagCASCODE
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(104): error MIDL2003: redefinition : tagCAPROPVARIANT
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(105): error MIDL2003: redefinition : tagCAH
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(106): error MIDL2003: redefinition : tagCAUH
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(107): error MIDL2003: redefinition : tagCALPSTR
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(108): error MIDL2003: redefinition : tagCALPWSTR
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(109): error MIDL2003: redefinition : tagCAFILETIME
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(110): error MIDL2003: redefinition : tagCACLIPDATA
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(111): error MIDL2003: redefinition : tagCACLSID
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(276): error MIDL2003: redefinition : tag_inner_PROPVARIANT
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(309): error MIDL2003: redefinition : PID_DICTIONARY
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(310): error MIDL2003: redefinition : PID_CODEPAGE
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(311): error MIDL2003: redefinition : PID_FIRST_USABLE
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(312): error MIDL2003: redefinition : PID_FIRST_NAME_DEFAULT
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(313): error MIDL2003: redefinition : PID_LOCALE
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(314): error MIDL2003: redefinition : PID_MODIFY_TIME
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(315): error MIDL2003: redefinition : PID_SECURITY
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(316): error MIDL2003: redefinition : PID_BEHAVIOR
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(317): error MIDL2003: redefinition : PID_ILLEGAL
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(319): error MIDL2003: redefinition : PID_MIN_READONLY
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(320): error MIDL2003: redefinition : PID_MAX_READONLY
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(322): error MIDL2003: redefinition : PRSPEC_INVALID
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(323): error MIDL2003: redefinition : PRSPEC_LPWSTR
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(324): error MIDL2003: redefinition : PRSPEC_PROPID
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(339): error MIDL2003: redefinition : tagPROPSPEC
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(348): error MIDL2003: redefinition : tagSTATPROPSTG
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(368): error MIDL2003: redefinition : tagSTATPROPSETSTG
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(377): error MIDL2003: redefinition : IPropertyStorage
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(509): error MIDL2003: redefinition : IPropertySetStorage
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(546): error MIDL2003: redefinition : IEnumSTATPROPSTG
c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\propidlbase.idl(586): error MIDL2003: redefinition : IEnumSTATPROPSETSTG
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\ocidl.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\comcat.idl
Processing C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\include\atliface.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\oleacc.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\shtypes.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\MsHTML.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\dimm.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\dispex.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared\dxgitype.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared\dxgicommon.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared\dxgiformat.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\MsHtmHst.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\docobj.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\ExDisp.idl
Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\ObjSafe.idl
.\vc140.idl(38): warning MIDL2214: semantic check incomplete due to previous errors
LINK : fatal error LNK1240: failed to compile IDL content
First of all, using ATL attributes is not a good idea overall. You are referring to MSDN section which belongs to Visual Studio 2008, and ATL attributes were deprecated soon.
An edit of MyIncludes.h that worked for me with latest VS2017 (the rest is per the walkthrough steps):
#pragma once
#include <sdkddkver.h> // <<--- This is the actual edit compared to MSDN article
#define _USRDLL
#define _ATL_ATTRIBUTES
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
using namespace ATL;
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 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
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.