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
Related
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.
Have the following code which compiles and runs fine in Visual C++ 2013, and the C++14 standard on http://cpp.sh. However, on Visual C++ 2017 ( ver 15.9.3 ), it gives an error message... which is maybe a bug?
Code is:
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
vector<long> v1 = {1}, v2 = {9};
swap<vector<long>>(v1, v2);
cout << "v1.front(): " << v1.front() << endl;
cout << "v2.front(): " << v2.front() << endl;
return 0;
}
I should note that if I comment out swap() function, then it compiles and runs ok. The error messages are all resulting from the call to swap().
Error messages are:
maptest.cpp
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2048): error C2039: '_Alloc': is not a member of 'std::vector<long,std::allocator<_Ty>>'
with
[
_Ty=long
]
maptest.cpp(9): note: see declaration of 'std::vector<long,std::allocator<_Ty>>'
with
[
_Ty=long
]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2096): note: see reference to class template instantiation 'std::_Vb_iter_base<_Alvbase_wrapped>' being compiled
with
[
_Alvbase_wrapped=std::vector<long,std::allocator<long>>
]
maptest.cpp(11): note: see reference to class template instantiation 'std::_Vb_reference<std::vector<long,std::allocator<_Ty>>>' being compiled
with
[
_Ty=long
]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2048): error C2061: syntax error: identifier '_Alloc'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2049): error C2065: '_Alvbase': undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2049): error C2923: 'std::allocator_traits': '_Alvbase' is not a valid template type argument for parameter '_Alloc'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2049): error C2955: 'std::allocator_traits': use of class template requires template argument list
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\xmemory0(903): note: see declaration of 'std::allocator_traits'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2049): error C2039: 'size_type': is not a member of 'std::allocator_traits<_Alloc>'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2049): error C2061: syntax error: identifier 'size_type'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2050): error C2065: '_Alvbase': undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2050): error C2923: 'std::allocator_traits': '_Alvbase' is not a valid template type argument for parameter '_Alloc'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2050): error C2955: 'std::allocator_traits': use of class template requires template argument list
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\xmemory0(903): note: see declaration of 'std::allocator_traits'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2050): error C2039: 'difference_type': is not a member of 'std::allocator_traits<_Alloc>'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2050): error C2061: syntax error: identifier 'difference_type'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2051): error C2065: '_Alvbase': undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2051): error C2923: 'std::_Rebind_alloc_t': '_Alvbase' is not a valid template type argument for parameter '_Alloc'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2058): error C2061: syntax error: identifier '_Sizet'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2065): error C2061: syntax error: identifier '_Sizet'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2072): error C2061: syntax error: identifier '_Sizet'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2089): error C3646: '_Myoff': unknown override specifier
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vector(2089): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
std::swap is overloaded for std::vector as
template< class T, class Alloc>
void swap(vector<T,Alloc>& lhs, vector<T,Alloc>& rhs);
The correct template arguments for your given vector would be T=long, Alloc = std::allocator<long>. The proper way to call swap (or almost any other templated function) on an std::vector is to simply drop the explicit template argument specification altogether and let template argument deduction do its work.
I created a fresh C++ (empty) project in VS2015, and then placed the Eigen 3.3.1 source code in an 'inc' folder in solution dir, such that the path to Matrix.h, for example, is inc/Eigen/Core/. I have set this inc/ path as an additional include directory, and have also tried with inc/Eigen/ as another include directory in case the files had issues including each other, but this changed nothing.
In main.cpp, I have the following:
#include "Eigen/Core/Matrix.h"
int main()
{
return 0;
}
This gives me, when compiling for x64:
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(18): error C2988: unrecognizable template declaration/definition
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(18): error C2143: syntax error: missing ';' before '<'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(18): error C2059: syntax error: '<'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(19): error C2143: syntax error: missing ';' before '{'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(19): error C2447: '{': missing function header (old-style formal list?)
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(179): error C2143: syntax error: missing ',' before '<'
1> c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(404): note: see reference to class template instantiation 'Eigen::Matrix<_Scalar,_Rows,_Cols,_Options,_MaxRows,_MaxCols>' being compiled
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(186): error C2143: syntax error: missing ';' before '<'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(186): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(186): error C2238: unexpected token(s) preceding ';'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(192): error C2653: 'Base': is not a class or namespace name
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(192): error C2144: syntax error: 'int' should be preceded by ';'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(192): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(192): warning C4183: 'EIGEN_DENSE_PUBLIC_INTERFACE': missing return type; assumed to be a member function returning 'int'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(192): error C3646: 'PlainObject': unknown override specifier
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(194): error C2653: 'Base': is not a class or namespace name
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(195): error C2653: 'Base': is not a class or namespace name
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(206): error C3646: 'EIGEN_STRONG_INLINE': unknown override specifier
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(206): error C3646: 'Matrix': unknown override specifier
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(206): error C2143: syntax error: missing ';' before '&'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(206): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(207): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(223): error C2061: syntax error: identifier 'EIGEN_STRONG_INLINE'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(237): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(243): error C2061: syntax error: identifier 'EIGEN_STRONG_INLINE'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(259): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(14): fatal error C1075: the left brace '{' was unmatched at the end of the file
Which complains about line 18 of Matrix.h:
#ifndef EIGEN_MATRIX_H
#define EIGEN_MATRIX_H
namespace Eigen {
namespace internal {
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
struct traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > // line 18
{
private:
// etc...
Similar issues occur with any other Eigen #include. Have I missed some required #include ordering or some compile flag or setting? Thanks!
You must copy the entire Eigen directory not just the src subfolder. And you must not include files from the src subfolder directly, but include the files in the Eigen directory. E.g., #include <Eigen/Core> will include all core functionality, #include <Eigen/Dense> will include all dense functionality (this includes Core, Geometry and the decompositions).
so i'm doing a uni project and when i try to compile a weird error pops up.I've read it might be from circular dependencies but i've checked and thats not the problem here's the header code :
#ifndef __ScheduleHeader_H_INCLUDED__
#define __ScheduleHeader_H_INCLUDED__
#include "TrainStationHeader.h"
class Schedule
{
friend class ScheduleIterator;
public:
//get data functions
std::string getFromCity() { return fromCity; }
std::string getToCity() { return toCity; }
std::string getTrainID() { return trainID; }
std::string getDate();
std::string getTime();
std::string getTimeForTickets();
std::string getPrice() { return price; }
//set data functions + validation on the input data
bool setFromCity();
bool setToCity();
void setDate();
void setTime();
bool setTrainID();
void setPrice();
std::string createScheduleLine();
private:
int validateDate(struct tm,struct tm);
int validateTime(struct tm,struct tm);
std::string scheduleFileName;
std::string fromCity;
std::string toCity;
struct tm dateAndTime;
std::string trainID;
std::string price;
};
#endif
I've added the friend because i have a Schedule object in another class as private.The error when i compile is :
c:\program files (x86)\windows kits\8.0\include\um\schedule.h(60): error C2146: syntax error : missing ';' before identifier 'Type'
1>c:\program files (x86)\windows kits\8.0\include\um\schedule.h(60): 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\schedule.h(61): error C2146: syntax error : missing ';' before identifier 'Offset'
1>c:\program files (x86)\windows kits\8.0\include\um\schedule.h(61): 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\schedule.h(68): error C2146: syntax error : missing ';' before identifier 'Size'
1>c:\program files (x86)\windows kits\8.0\include\um\schedule.h(68): 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\schedule.h(69): error C2146: syntax error : missing ';' before identifier 'Bandwidth'
1>c:\program files (x86)\windows kits\8.0\include\um\schedule.h(69): 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\schedule.h(70): error C2146: syntax error : missing ';' before identifier 'NumberOfSchedules'
1>c:\program files (x86)\windows kits\8.0\include\um\schedule.h(70): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
PS:I'm using MC VS 2012
here's the TrainStation.h , Its just a bunch of functions and libraries i use across the majority of the classes (i know it's not the best practice) :
#ifndef __TrainStation_H_INCLUDED__
#define __TrainStation_H_INCLUDED__
#include <iostream>
#include <string>
#include <fstream>
#include <locale>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <vector>
std::string removeWhiteSpace(std::string a);
//Resieves the file on wich to operate upon and what to search for.
//If it finds it it returns the line on wich it has been found ,if not returns -1
int checkContent(std::string FileName, std::string target);
//Give the Function the File Name with wich you would like to work and the target that you would like to delete
//It works by copying everything exept the target string to another file then renames it and deletes the old file
int deleteContent(std::string File,std::string target);
void renameFile(std::string , std::string);
bool checkFileState(std::ifstream &file);
#endif
the error message indicates error in "C:\program files (x86)\windows kits\8.0\include\um\schedule.h" that is part of installation of VS or additional SDKs. You quote a completely different header file.
If you can't figure out the error, ask for preprocessor output and read that to see the problem. /SHOWINCLUDES may also help.
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.