Boost::asio linking; identifier not found; C++ - c++

I googled the error lines of my problem and got hardly any hits and I don't speak russian. I also found this, but it doesn't seem to help me.
This is my code
#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
int main() {
boost::asio::io_service io;
boost::asio::deadline_timer t(io,boost::posix_time::seconds(5));
t.wait();
std::cout << "Hello World" << std::endl;
return 0;
}
These be my error messages:
1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------
1> Main.cpp
1>c:\sdk\boost\asio\detail\impl\win_thread.ipp(52): error C2039: 'QueueUserAPC' : is not a member of '`global namespace''
1>c:\sdk\boost\asio\detail\impl\win_thread.ipp(52): error C3861: 'QueueUserAPC': identifier not found
1>c:\sdk\boost\asio\detail\impl\win_object_handle_service.ipp(374): error C3861: 'RegisterWaitForSingleObject': identifier not found
1>c:\sdk\boost\asio\detail\impl\win_object_handle_service.ipp(416): error C3861: 'RegisterWaitForSingleObject': identifier not found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Any insights would be appreciated, thanks!
EDIT
Adding #include <Windows.h> before the headers changed the error messages to
1>c:\program files (x86)\windows kits\8.0\include\um\prsht.h(607): error C2146: syntax error : missing ';' before identifier 'hdr'
1>c:\program files (x86)\windows kits\8.0\include\um\prsht.h(607): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\8.0\include\um\windows.h(247): warning C4193: #pragma warning(pop) : no matching '#pragma warning(push)'
1>c:\sdk\boost\asio\detail\socket_types.hpp(22): fatal error C1189: #error : WinSock.h has already been included
prsht.h:
tracking that down lead me to find this:
typedef struct _PSHNOTIFY
{
NMHDR hdr; //line 607 NMHDR is undefined.
LPARAM lParam;
} PSHNOTIFY, *LPPSHNOTIFY;
Not real sure where to go from here.

Related

My header file seems to be correct but it is throwing a lot of errors

I am writing an interface program and I am using classes to write the interface as well as some of the other options within the program. This is what I have written so far:
#ifndef INTERFACE_H
#define INTERFACE_H
#include <iostream>
#include <vector>
#include <string>
class Interface
{
private:
typedef vector<string> programType;
programType programCode;
public:
void startInterface()
{
char q, input;
do
{
cout << "PySUB Interpreter 1.0 on Windows (September 2020)" << endl;
cout << "Enter program lines or read(<filename>.py) at command line interface" << endl;
cout << "Type 'help' for more information or 'quit' to exit" << endl;
} while (input != q);
}
void quit();
void help();
void show();
void clear();
};
#endif
The errors that I am getting are:
Build started...
1>------ Build started: Project: pysub1, Configuration: Debug x64 ------
1>interface.cpp
1>C:\Users\Johnathon\source\repos\pysub1\pysub1\interface.h(11,16): error C2143: syntax error: missing ';' before '<'
1>C:\Users\Johnathon\source\repos\pysub1\pysub1\interface.h(11,16): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Users\Johnathon\source\repos\pysub1\pysub1\interface.h(11,36): error C2238: unexpected token(s) preceding ';'
1>C:\Users\Johnathon\source\repos\pysub1\pysub1\interface.h(12,14): error C3646: 'programCode': unknown override specifier
1>C:\Users\Johnathon\source\repos\pysub1\pysub1\interface.h(12,25): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Users\Johnathon\source\repos\pysub1\pysub1\interface.h(21,72): error C2065: 'endl': undeclared identifier
1>C:\Users\Johnathon\source\repos\pysub1\pysub1\interface.h(22,91): error C2065: 'endl': undeclared identifier
1>C:\Users\Johnathon\source\repos\pysub1\pysub1\interface.h(23,73): error C2065: 'endl': undeclared identifier
1>Done building project "pysub1.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
How do I resolve this?
The problem here is that you don't specify the namespace of cout, endl, etc. You should either change them them to std::cout and so on, or write using namespace std at the top of your file (which is generally considered bad practice, but will do just fine in your example).

Multiple errors from 3rd party libraries from PCL when building simple point cloud visualization code in Visual Studio 2019

I'm new to PCL (point cloud library) and I was trying to build a simple point cloud visualization code I found on their website in Visual Studio 2019. When I tried to build it, it gives me errors on the header files found in the PCL folder.
I downloaded PCL 1.6 and there are 3rd party header files included. I checked if I correctly included the necessary directories needed to build the code, nothing was missing. I'm not sure how to approach the errors since they are caused by the header files included in the PCL library. Any help would be greatly appreciated.
P.S. I'm sorry for the long code and error message. This is my first time posting a problem here.
Below is the simple point cloud visualization code I found in the PCl website:
#include <pcl/visualization/cloud_viewer.h>
#include <iostream>
#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>
int user_data;
void
viewerOneOff(pcl::visualization::PCLVisualizer& viewer)
{
viewer.setBackgroundColor(1.0, 0.5, 1.0);
pcl::PointXYZ o;
o.x = 1.0;
o.y = 0;
o.z = 0;
viewer.addSphere(o, 0.25, "sphere", 0);
std::cout << "i only run once" << std::endl;
}
void
viewerPsycho(pcl::visualization::PCLVisualizer& viewer)
{
static unsigned count = 0;
std::stringstream ss;
ss << "Once per viewer loop: " << count++;
viewer.removeShape("text", 0);
viewer.addText(ss.str(), 200, 300, "text", 0);
//FIXME: possible race condition here:
user_data++;
}
int
main()
{
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGBA>);
pcl::io::loadPCDFile("my_point_cloud.pcd", *cloud);
pcl::visualization::CloudViewer viewer("Cloud Viewer");
//blocks until the cloud is actually rendered
viewer.showCloud(cloud);
//use the following functions to get access to the underlying more advanced/powerful
//PCLVisualizer
//This will only get called once
viewer.runOnVisualizationThreadOnce(viewerOneOff);
//This will get called once per visualization iteration
viewer.runOnVisualizationThread(viewerPsycho);
while (!viewer.wasStopped())
{
//you can also do cool processing here
//FIXME: Note that this is running in a separate thread from viewerPsycho
//and you should guard against race conditions yourself...
user_data++;
}
return 0;
}
Here is the Header file from the PCL folder that causes the error:
#ifndef EIGEN_VECTORBLOCK_H
#define EIGEN_VECTORBLOCK_H
namespace Eigen {
namespace internal {
template<typename VectorType, int Size>
struct traits<VectorBlock<VectorType, Size> >
: public traits<Block<VectorType,
traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
traits<VectorType>::Flags & RowMajorBit ? Size : 1> >
{
};
}
template<typename VectorType, int Size> class VectorBlock
: public Block<VectorType,
internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1>
{
typedef Block<VectorType,
internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1> Base;
enum {
IsColVector = !(internal::traits<VectorType>::Flags & RowMajorBit)
};
public:
EIGEN_DENSE_PUBLIC_INTERFACE(VectorBlock)
using Base::operator=;
EIGEN_DEVICE_FUNC
inline VectorBlock(VectorType& vector, Index start, Index size)
: Base(vector,
IsColVector ? start : 0, IsColVector ? 0 : start,
IsColVector ? size : 1, IsColVector ? 1 : size)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock);
}
EIGEN_DEVICE_FUNC
inline VectorBlock(VectorType& vector, Index start)
: Base(vector, IsColVector ? start : 0, IsColVector ? 0 : start)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock);
}
};
} // end namespace Eigen
#endif // EIGEN_VECTORBLOCK_H
Below is the error message I keep getting when I build the code (I didn't include a few lines of error since my post exceeded the character count):
1>------ Build started: Project: PCL_trial, Configuration: Debug x64 ------
1>PCL_trial.cpp
1>Unknown compiler version - please run the configure tests and report the results
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C2039: 'type': is not a member of '`global namespace''
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C2238: unexpected token(s) preceding ';'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C2976: 'Eigen::Eigen::internal::traits': too few template arguments
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(18): message : see declaration of 'Eigen::Eigen::internal::traits'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C2039: 'StorageKind': is not a member of 'Eigen::Eigen::internal::traits'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(18): message : see declaration of 'Eigen::Eigen::internal::traits'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C3646: 'StorageKind': unknown override specifier
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C2039: 'Index': is not a member of 'Eigen::Eigen::internal::traits'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(18): message : see declaration of 'Eigen::Eigen::internal::traits'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C3646: 'Index': unknown override specifier
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(75,1): error C2144: syntax error: 'Eigen::Eigen::VectorBlock<VectorType,Size>' should be preceded by ';'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(74,5): error C7525: inline variables require at least '/std:c++17'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(75,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(86,1): error C2144: syntax error: 'Eigen::Eigen::VectorBlock<VectorType,Size>' should be preceded by ';'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(85,5): error C7525: inline variables require at least '/std:c++17'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(86,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\Transpose.h(76,5): error C2976: 'Eigen::Eigen::internal::traits': too few template arguments
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(18): message : see declaration of 'Eigen::Eigen::internal::traits'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\Transpose.h(95): message : see reference to class template instantiation 'Eigen::Transpose<Derived>' being compiled
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\Transpose.h(76,5): error C2039: 'Scalar': is not a member of 'Eigen::Eigen::internal::traits'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(18): message : see declaration of 'Eigen::Eigen::internal::traits'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\Transpose.h(76,1): error C3646: 'Scalar': unknown override specifier
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\Transpose.h(76,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\Transpose.h(76,1): error C2039: 'NumTraits': is not a member of 'Eigen::Eigen'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(14): message : see declaration of 'Eigen::Eigen'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\Transpose.h(76,1): error C2059: syntax error: '<'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\Diagonal.h(83,1): error C1003: error count exceeds 100; stopping compilation
1>Done building project "PCL_trial.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
UPDATE: I have downloaded PCL 1.9.1 and included its directory to my project. I also downloaded Boost 1.70.0 to fix the error with positioning.hpp. My problem now is the error with low_level_io.h. Below is the error I'm getting when building the project:
1>PCL_trial.cpp
1>The use of BOOST_*_ENDIAN and BOOST_BYTE_ORDER is deprecated. Please include <boost/predef/other/endian.h> and use BOOST_ENDIAN_*_BYTE instead
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(60,16): error C2039: '_open': is not a member of '`global namespace''
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(60,21): error C3861: '_open': identifier not found
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(70,16): error C2039: '_open': is not a member of '`global namespace''
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(70,21): error C3861: '_open': identifier not found
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(80,16): error C2039: '_close': is not a member of '`global namespace''
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(80,22): error C3861: '_close': identifier not found
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(90,16): error C2039: '_lseek': is not a member of '`global namespace''
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(90,22): error C3861: '_lseek': identifier not found
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(100,16): error C2039: '_read': is not a member of '`global namespace''
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(100,21): error C3861: '_read': identifier not found
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(110,16): error C2039: '_write': is not a member of '`global namespace''
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(110,22): error C3861: '_write': identifier not found
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(120,16): error C2039: '_chsize': is not a member of '`global namespace''
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(120,23): error C3861: '_chsize': identifier not found
1>Done building project "PCL_trial.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Does anyone know how to fix this? Any help would be appreciated.
To make it easier, I suggest you download the all-in-one exe file and install it, then create a console c++ project, add include and lib files manually.
I successfully built the program by using CMake and PCL 1.9.1. Apparently, it is easier to use CMake because it automatically adds the necessary include and library directories to build the program.

Unable to compile PCAP Program in Visual studio

Following is the code to retrieve MAC addresses from my AirPcap Adapter. But I am facing issues when executing the program: Please help me in resolving this error.
#include <stdio.h>
#include <conio.h>
#include "packet32.h"
#include <ntddndis.h>
#include "StdAfx.h"
#define Max_Num_Adapter 10
char AdapterList[Max_Num_Adapter][1024];
int main()
{
LPADAPTER lpAdapter = 0;
int i;
DWORD dwErrorCode;
WCHAR AdapterName[8192];
WCHAR *temp,*temp1;
int AdapterNum=0,Open;
ULONG AdapterLength;
PPACKET_OID_DATA OidData;
BOOLEAN Status;
//
// Obtain the name of the adapters installed on this machine
//
printf("Packet.dll test application. Library version:%s\n", PacketGetVersion());
printf("Adapters installed:\n");
i=0;
AdapterLength = sizeof(AdapterName);
if(PacketGetAdapterNames(AdapterName,&AdapterLength)==FALSE){
printf("Unable to retrieve the list of the adapters!\n");
return -1;
}
temp=AdapterName;
temp1=AdapterName;
while ((*temp!='\0')||(*(temp-1)!='\0'))
{
if (*temp=='\0')
{
memcpy(AdapterList[i],temp1,temp-temp1);
temp1=temp+1;
i++;
}
temp++;
}
AdapterNum=i;
for (i=0;i<AdapterNum;i++)
printf("\n%d- %s\n",i+1,AdapterList[i]);
printf("\n");
do
{
printf("Select the number of the adapter to open : ");
scanf_s("%d",&Open);
if (Open>AdapterNum) printf("\nThe number must be smaller than %d",AdapterNum);
} while (Open>AdapterNum);
//
// Open the selected adapter
//
lpAdapter = PacketOpenAdapter(AdapterList[Open-1]);
if (!lpAdapter || (lpAdapter->hFile == INVALID_HANDLE_VALUE))
{
dwErrorCode=GetLastError();
printf("Unable to open the adapter, Error Code : %lx\n",dwErrorCode);
return -1;
}
//
// Allocate a buffer to get the MAC adress
//
OidData = (PPACKET_OID_DATA)malloc(6 + sizeof(PACKET_OID_DATA));
if (OidData == NULL)
{
printf("error allocating memory!\n");
PacketCloseAdapter(lpAdapter);
return -1;
}
//
// Retrieve the adapter MAC querying the NIC driver
//
OidData->Oid = OID_802_3_CURRENT_ADDRESS;
OidData->Length = 6;
ZeroMemory(OidData->Data, 6);
Status = PacketRequest(lpAdapter, FALSE, OidData);
if(Status)
{
printf("The MAC address of the adapter is %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
(OidData->Data)[0],
(OidData->Data)[1],
(OidData->Data)[2],
(OidData->Data)[3],
(OidData->Data)[4],
(OidData->Data)[5]);
}
else
{
printf("error retrieving the MAC address of the adapter!\n");
}
free(OidData);
PacketCloseAdapter(lpAdapter);
return (0);
}
Following are the errors:
1>------ Build started: Project: qqq, Configuration: Release Win32 ------
1>Build started 5/29/2015 3:10:00 PM.
1>InitializeBuildStatus:
1> Touching "Release\qqq.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1> ppp.cpp
1>ppp.cpp(35): warning C4627: '#include <conio.h>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>ppp.cpp(36): warning C4627: '#include "packet32.h"': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>ppp.cpp(37): warning C4627: '#include <ntddndis.h>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>ppp.cpp(44): error C2065: 'LPADAPTER' : undeclared identifier
1>ppp.cpp(44): error C2146: syntax error : missing ';' before identifier 'lpAdapter'
1>ppp.cpp(44): error C2065: 'lpAdapter' : undeclared identifier
1>ppp.cpp(46): error C2065: 'DWORD' : undeclared identifier
1>ppp.cpp(46): error C2146: syntax error : missing ';' before identifier 'dwErrorCode'
1>ppp.cpp(46): error C2065: 'dwErrorCode' : undeclared identifier
1>ppp.cpp(47): error C2065: 'WCHAR' : undeclared identifier
1>ppp.cpp(47): error C2146: syntax error : missing ';' before identifier 'AdapterName'
1>ppp.cpp(47): error C2065: 'AdapterName' : undeclared identifier
1>ppp.cpp(48): error C2065: 'WCHAR' : undeclared identifier
1>ppp.cpp(48): error C2065: 'temp' : undeclared identifier
1>ppp.cpp(48): error C2065: 'temp1' : undeclared identifier
1>ppp.cpp(50): error C2065: 'ULONG' : undeclared identifier
1>ppp.cpp(50): error C2146: syntax error : missing ';' before identifier 'AdapterLength'
1>ppp.cpp(50): error C2065: 'AdapterLength' : undeclared identifier
1>ppp.cpp(51): error C2065: 'PPACKET_OID_DATA' : undeclared identifier
1>ppp.cpp(51): error C2146: syntax error : missing ';' before identifier 'OidData'
1>ppp.cpp(51): error C2065: 'OidData' : undeclared identifier
1>ppp.cpp(52): error C2065: 'BOOLEAN' : undeclared identifier
1>ppp.cpp(52): error C2146: syntax error : missing ';' before identifier 'Status'
1>ppp.cpp(52): error C2065: 'Status' : undeclared identifier
1>ppp.cpp(58): error C3861: 'PacketGetVersion': identifier not found
1>ppp.cpp(63): error C2065: 'AdapterLength' : undeclared identifier
1>ppp.cpp(63): error C2065: 'AdapterName' : undeclared identifier
1>ppp.cpp(63): error C2070: ''unknown-type'': illegal sizeof operand
1>ppp.cpp(65): error C2065: 'AdapterName' : undeclared identifier
1>ppp.cpp(65): error C2065: 'AdapterLength' : undeclared identifier
1>ppp.cpp(65): error C2065: 'FALSE' : undeclared identifier
1>ppp.cpp(65): error C3861: 'PacketGetAdapterNames': identifier not found
1>ppp.cpp(69): error C2065: 'temp' : undeclared identifier
1>ppp.cpp(69): error C2065: 'AdapterName' : undeclared identifier
1>ppp.cpp(70): error C2065: 'temp1' : undeclared identifier
1>ppp.cpp(70): error C2065: 'AdapterName' : undeclared identifier
1>ppp.cpp(72): error C2065: 'temp' : undeclared identifier
1>ppp.cpp(72): error C2065: 'temp' : undeclared identifier
1>ppp.cpp(72): fatal error C1903: unable to recover from previous error(s); stopping compilation
1> qqq.cpp
1>qqq.cpp(36): warning C4627: '#include <conio.h>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>qqq.cpp(155): error C3861: '_kbhit': identifier not found
1>qqq.cpp(197): error C2440: '=' : cannot convert from 'PVOID' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>qqq.cpp(202): error C3861: '_kbhit': identifier not found
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.33
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I am facing undeclared Identifier issue. Please guide me on resolving this issue.
stdafx.h needs to be included first before all other headers. This is a requirement of the VC++ compiler. If stdafx.h is included after other header files those header files will be skipped by the compiler. When this happens it is unable to resolve the symbols declared in those headers.

Visual Studio 2012 Express compiler not linking header files together correctly

I am setting up some framework for a little 2D game. Right now, I just have a few classes, but I am immediately falling into compiler problems.
I have run this program with only the main function, so I can confirm that the Allegro (graphics library) library linking has worked.
I have put all my header files (.h) under the "Header Files" section in the Solution explorer and all my source (.cpp) in the "Source Files" section. I have only modified settings from default as according to this Allegro tutorial: http://wiki.allegro.cc/index.php?title=Windows,_Visual_Studio_2010_and_Allegro_5. It should not have affected anything in a destructive way.
I have several files, so I will list each one. I will skip some code to reduce size and redundancy. When I omit any code or do anything not verbatim, I will put a comment in the code saying so. (EDIT: I actually did not skip any code)
main.cpp
#include "common.h"
int main(int argc, char **argv)
{
ALLEGRO_DISPLAY *display = NULL;
World* world = new World(640, 480);
if(!al_init()) {
fprintf(stderr, "failed to initialize allegro!\n");
return -1;
}
display = al_create_display(640, 480);
if(!display) {
fprintf(stderr, "failed to create display!\n");
return -1;
}
al_clear_to_color(al_map_rgb(0,0,0));
world->draw(display);
al_flip_display();
al_rest(10.0);
al_destroy_display(display);
return 0;
}
common.h
#if !defined(COMMON_INC)
#define COMMON_INC
#include "World.h"
#include "Pane.h"
#include <stdio.h>
#include <allegro5/allegro.h>
#endif
World.h
#if !defined(WORLD_INC)
#define WORLD_INC
#include "common.h"
#include "Pane.h"
class World{
public:
World(int wp, int hp);
void draw(ALLEGRO_DISPLAY* display);
void update();
protected:
private:
Pane* panel;
int heightPix, widthPix;
};
#endif
World.cpp
#include "common.h"
World::World(int wp, int hp){
widthPix = wp;
heightPix = hp;
panel = new Pane(this, 10, 10, 300, 400);
return;
}
void World::draw(ALLEGRO_DISPLAY* display){
panel->draw(display);
return;
}
Pane.h
#if !defined(PANE_INC)
#define PANE_INC
#include "common.h"
class Pane{
public:
Pane(World* w, int xv, int yv, int wi, int he);
World* getWorld();
int getZ();
void draw(ALLEGRO_DISPLAY* display);
ALLEGRO_BITMAP* getBackground();
protected:
void setXY(int xv, int yv);
void setWidthHeight(int wi, int he);
void setZ(int zv);
void setBackground(ALLEGRO_BITMAP* ba);
private:
int z;
int x, y; //pixels
int width, height; //pixels
World* world;
ALLEGRO_BITMAP* background;
};
#endif
Pane.cpp
#include "common.h"
Pane::Pane(World* w, int xv, int yv, int wi, int he){
this->setWidthHeight(wi, he);
this->setXY(xv, yv);
this->world = w;
}
World* Pane::getWorld(){
return world;
}
void Pane::setXY(int xv, int yv){
x = xv;
y = yv;
return;
}
void Pane::setWidthHeight(int wi, int he){\
width = wi;
height = he;
return;
}
void Pane::setZ(int zv){
z = zv;
return;
}
void Pane::draw(ALLEGRO_DISPLAY* display){
if(background != NULL)
al_draw_bitmap(background, x, y, 0);
else{
background = al_create_bitmap(width, height);
al_set_target_bitmap(background);
al_clear_to_color(al_map_rgb(255, 0, 255));
al_set_target_bitmap(al_get_backbuffer(display));
al_draw_bitmap(background, x, y, 0);
}
return;
}
The compiler produces this error report upon building: (I called the game madscientist because it is supposed to be alchemy-themed)
1>------ Build started: Project: MadScientist, Configuration: Debug Win32 ------
1> main.cpp
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(8): error C2061: syntax error : identifier 'World'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(9): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(9): warning C4183: 'getWorld': missing return type; assumed to be a member function returning 'int'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(11): error C2061: syntax error : identifier 'ALLEGRO_DISPLAY'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(12): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(12): warning C4183: 'getBackground': missing return type; assumed to be a member function returning 'int'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(18): error C2061: syntax error : identifier 'ALLEGRO_BITMAP'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(24): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(24): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(25): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(25): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.h(10): error C2061: syntax error : identifier 'ALLEGRO_DISPLAY'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\main.cpp(22): error C2660: 'World::draw' : function does not take 1 arguments
1> World.cpp
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(8): error C2061: syntax error : identifier 'World'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(9): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(9): warning C4183: 'getWorld': missing return type; assumed to be a member function returning 'int'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(11): error C2061: syntax error : identifier 'ALLEGRO_DISPLAY'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(12): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(12): warning C4183: 'getBackground': missing return type; assumed to be a member function returning 'int'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(18): error C2061: syntax error : identifier 'ALLEGRO_BITMAP'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(24): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(24): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(25): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(25): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.h(10): error C2061: syntax error : identifier 'ALLEGRO_DISPLAY'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.cpp(6): error C2661: 'Pane::Pane' : no overloaded function takes 5 arguments
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.cpp(10): error C2511: 'void World::draw(ALLEGRO_DISPLAY *)' : overloaded member function not found in 'World'
1> c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.h(7) : see declaration of 'World'
1> Pane.cpp
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(8): error C2061: syntax error : identifier 'World'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(9): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(9): warning C4183: 'getWorld': missing return type; assumed to be a member function returning 'int'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(11): error C2061: syntax error : identifier 'ALLEGRO_DISPLAY'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(12): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(12): warning C4183: 'getBackground': missing return type; assumed to be a member function returning 'int'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(18): error C2061: syntax error : identifier 'ALLEGRO_BITMAP'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(24): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(24): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(25): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(25): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.h(10): error C2061: syntax error : identifier 'ALLEGRO_DISPLAY'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.cpp(3): error C2511: 'Pane::Pane(World *,int,int,int,int)' : overloaded member function not found in 'Pane'
1> c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(6) : see declaration of 'Pane'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.cpp(9): error C2556: 'World *Pane::getWorld(void)' : overloaded function differs only by return type from 'int *Pane::getWorld(void)'
1> c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(9) : see declaration of 'Pane::getWorld'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.cpp(9): error C2371: 'Pane::getWorld' : redefinition; different basic types
1> c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(9) : see declaration of 'Pane::getWorld'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.cpp(10): error C2065: 'world' : undeclared identifier
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.cpp(30): error C2511: 'void Pane::draw(ALLEGRO_DISPLAY *)' : overloaded member function not found in 'Pane'
1> c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(6) : see declaration of 'Pane'
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
You have all of the info that I do. I will summarize it for you to save the trouble of looking through everything.
There are classes separated into header interfaces and source implementations
common.h is included by all files. It itself includes all of the class definitions in the other header files
When compiled, the compiler does not recognize classes defined in other header files as data types. Errors, as you would expect, cascade down.
The real-time error checker does not register any errors. When hovering over the word "World" when it is used as a datatype in Pane, for example, it recognizes the type perfectly. The real-time error checker is the feature that red underlines errors before compiler time.
This Visual Studio 2012 Express is new except for the modifications mentioned earlier. The project was created as an empty C++ project. Before many headers and sources were add, the main function compiled correctly.
Thank you for any responses. If you have any questions, please ask. The problems I have with Visual Studio always irk me.
EDITS:
My circular header logic is guarded by the header guards. I don't think this redundancy is a problem.
I tried removing all includes from my header files except for includes to Allegro libraries. This seemed to work better, but there are still weird problems. Why the act of including is causing these data types to error is still a mystery. Here is the new error log:
1>------ Build started: Project: MadScientist, Configuration: Debug Win32 ------
1> main.cpp
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.h(16): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.h(16): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> World.cpp
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.h(16): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.h(16): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.cpp(6): error C2065: 'panel' : undeclared identifier
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.cpp(11): error C2065: 'panel' : undeclared identifier
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.cpp(11): error C2227: left of '->draw' must point to class/struct/union/generic type
1> type is ''unknown-type''
1> Pane.cpp
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.h(16): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.h(16): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
EDITS ROUND 2:
I switched my code around so the common.h only includes stdio and Allegro. All the header and source files include common.h and then any class's header file that they are using individually. Pane.cpp include Pane.h and common.h. World.h includes Pane.h and common.h.
Error log reads:
1>------ Build started: Project: MadScientist, Configuration: Debug Win32 ------
1> main.cpp
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(9): error C2061: syntax error : identifier 'World'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(10): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(10): warning C4183: 'getWorld': missing return type; assumed to be a member function returning 'int'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(25): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(25): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> World.cpp
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(9): error C2061: syntax error : identifier 'World'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(10): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(10): warning C4183: 'getWorld': missing return type; assumed to be a member function returning 'int'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(25): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\pane.h(25): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.cpp(7): error C2661: 'Pane::Pane' : no overloaded function takes 5 arguments
1> Pane.cpp
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.h(16): error C2143: syntax error : missing ';' before '*'
1>c:\users\ethoma\documents\visual studio 2012\projects\madscientist\madscientist\world.h(16): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
This is how I see my include order now:
main includes common
common defines COMMON_INC
common includes stdio and allegro
main includes World.h
World defines WORLD_INC
World includes common, which is blocked. But this should be okay because common is already included
World includes Pane
Pane defines PANE_INC
Pane includes common, which is blocked. But this should be okay because common is already included.
Pane includes World. This is blocked because main already included World. Shouldn't this be okay since World was already included. Why do I even have compiler guards if I need to include files many times over, once for each file that uses it?
EDITS ROUND 3:
I have learned a lot from the answers and comments here. It turns out that, according to Wikipedia, "circular dependencies are often introduced by inexperienced programmers who need to implement some kind of callback functionality." The mere fact that Pane uses World and World uses Pane is a design flaw. In Java, this was all fine for me. It was very easy; I thought that this was the best way to notify the entity that "possesses" an object of the object's actions.
It turns out that this is a bad design scheme. Objects should not have dependencies to their "possessors". Instead, I need to implement a observer system, where the Pane can tell the World that it has updated its state.
Reading wikipedia cleared up any questions that I had, so I now consider this question finished. Thanks to the contributors for putting up for a learning programmer.
You header files cannot be possibly linked correctly. You included your headers in circular fashion. Your header files include common.h, while common.h in turn includes other headers, like World.h and Pane.h.
This is not compilable by any compiler. You have to develop a hierarchy of headers, from low-level headers to high-level headers and make sure that higher-level headers include only lower-level headers. That way you will make sure you have no circular inclusions.
Anyway, why does your common.h include World.h and Pane.h? This looks like an obvious error. common.h is intended to be a low-level header. Let World.h and Pane.h include it, but don't include World.h and Pane.h into common.h.
Note, that header guards do not solve anything in this case. They simply make sure that the inclusion cycle will not get infinite. They break the cycle, but they don't help you to resolve circular dependencies between declarations, if such dependencies exist.
Look what happens in your case when processing main.cpp
main.cpp includes common.h
common.h defines COMMON_INC
common.h includes World.h
World.h defines WORLD_INC
World.h includes common.h. The whole common.h is skipped by include guards, because COMMON_INC got defined at step 2.
World.h includes Pane.h
Pane.h defines PANE_INC
Pane.h includes common.h. The whole common.h is skipped by include guards, because COMMON_INC got defined at step 2.
Pane.h referred to type World. Type World is unknown, since we haven't gotten to its definition in World.h yet. Error!
I think everything will compile even with the circular includes, if you make the following changes
In common.h you need to rearrange order of headers.
#include <allegro5/allegro.h>
#include "World.h"
#include "Pane.h"
#include <stdio.h>
In pane.h, after the #include common.h, add a forward declaration for class World
#include "common.h"
class World;
class Pane{
.....
I think this will make your errors disappear or atleast decrease them substantially.
My answer is based on the original code you put up, not on the Edit.

C++ header redefinition (ws2ipdef.h)

I use in my project a lot of includes (but every header file use header guards like
#ifndef _HEADER_H
#define _HEADER_H
...
#endif
and now I'm getting this errors from ws2ipdef.h (automatically included of windows.h):
c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(336) : error C2146: syntax error : missing ';' before identifier 'IN6_ADDR_EQUAL'
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(336) : error C2433: 'Boolean' : 'inline' not permitted on data declarations
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(336) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(337) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(344) : error C2064: term does not evaluate to a function taking 1 arguments
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(344) : warning C4508: 'IN6_ADDR_EQUAL' : function should return a value; 'void' return type assumed
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(354) : error C2146: syntax error : missing ';' before identifier 'IN6_IS_ADDR_UNSPECIFIED'
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(354) : error C2433: 'Boolean' : 'inline' not permitted on data declarations
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(354) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(354) : error C2086: 'int Boolean' : redefinition
1> c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(336) : see declaration of 'Boolean'
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(355) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(367) : error C2064: term does not evaluate to a function taking 1 arguments
1>c:\program files\microsoft sdks\windows\v7.0\include\ws2ipdef.h(367) : warning C4508: 'IN6_IS_ADDR_UNSPECIFIED' : function should return a value; 'void' return type assumed
In Interface.h (is included in some other files) I use:
#define WIN32_LEAN_AND_MEAN
// sockets
#include <winsock2.h>
#include "windows.h"
#include <ws2tcpip.h>
How can I resolve this issue or any hints?
Thx
Try using #pragma once instead of of ifndef guard, it specifies that the file will be included (opened) only once by the compiler when compiling a source code file. http://msdn.microsoft.com/en-us/library/4141z1cx.aspx
Solved it with an additional ifndef guard in Interface.h
#ifndef _READERCOMMUNICATION_H
#define WIN32_LEAN_AND_MEAN // to exlude some unnecessary windows headers (see windows.h)
// sockets
//#include <winsock2.h> // winsock 1 is enough for my project
#include <windows.h>
#include <ws2tcpip.h>
#endif