Boost thread.hpp include error - c++

I am able to include boost libraries in a simple sample project without any problem and it works fine. But as soon as I include #include <boost/thread.hpp> in one of my other project which is already using some other libraries, I am getting the following compilation errors:
1>ClCompile:
1> ThreadManager.cpp
1>C:\Boost\include\boost-1_63\boost/container/container_fwd.hpp(302): warning C4003: not enough actual parameters for macro 'dummy'
1>C:\Boost\include\boost-1_63\boost/container/container_fwd.hpp(302): error C2976: 'atl::Dummy' : too few template arguments
1>C:\program files\adaptive vision\adaptive vision studio 4.3 professional\sdk\include\ATL/Dummy.h(17) : see declaration of 'atl::Dummy'
1>C:\Boost\include\boost-1_63\boost/container/container_fwd.hpp(302): error C3484: syntax error: expected '->' before the return type
1>C:\Boost\include\boost-1_63\boost/container/container_fwd.hpp(302): error C2061: syntax error : identifier 'Get'
1>C:\Boost\include\boost-1_63\boost/container/container_fwd.hpp(302): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>
1>Build FAILED.
PS: If I include #include <boost/chrono.hpp> instead of #include <boost/thread.hpp> then there is no error.
PSS: I am using Windows, Visual Studio 2010 (that's why Boost)
Sample Code:
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
//Header for boost multithreading
//#include <boost/chrono.hpp>
#include <boost/thread.hpp>
namespace avs //Adaptive Vision
{
class MyProgram : public UserFilter
{
int Invoke()
{
//CODE
}
};
}

Related

Problems compiling xmsinterp using Boost Geometry

I am using Microsoft Visual Studio Community Edition 2022. I am trying to compile and use the xmsinterp library. This code has introduced me to Boost. I was able to compile the codes and get answers until I started including the Delauney Triangulation codes, which rely on the Boost geometry modules. I have included the following headers in my program.
// Boost Codes
#include <boost/bind/bind.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/export.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/unordered_set.hpp>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
//#include <boost/geometry/strategies/default_strategy.hpp>
//#include <boost/geometry/algorithms/centroid.hpp>
#include <boost/geometry/index/rtree.hpp>
using namespace boost::geometry;
#include <boost/unordered_map.hpp>
#include <boost/iterator/counting_iterator.hpp>
// xmscore codes...
#include <xmscore/math/math.h>
#include <xmscore/stl/utility.h>
#include <xmscore/xmscore/points/ptsfwd.h>
//#include <xmsgrid/geometry/GmBoostTypes.h>
#include <xmsgrid/geometry/geoms.h>
#include <xmsgrid/geometry/GmPtSearch.h>
#include <xmscore/misc/xmstype.h>
#include <xmscore/misc/XmError.h>
#include <xmscore/misc/XmConst.h>
// xmsgrid codes...
#include <xmsgrid/geometry/GmBoostTypes.h>
#include <xmsgrid/geometry/GmTriSearch.h>
// xmsinterp codes...
#include <new.h>
#include <xmscore/misc/xmstype.h>
#include <xmsinterp/interpolate/detail/InterpCt.h>
#include <xmscore/stl/vector.h>
#include <xmsinterp/interpolate/detail/InterpCt.cpp>
#include <xmsinterp/interpolate/detail/NodalFunc.cpp>
// xmsinterp test cases...
#include <xmsinterp/interpolate/InterpIdw.h>
#include <xmsinterp/interpolate/InterpLinear.h>
#include <xmsinterp/interpolate/InterpAnisotropic.h>
#include <xmsgrid/triangulate/TrTriangulator.h>
#include <xmsgrid/triangulate/TrTriangulatorPoints.h>
#include <xmsgrid/triangulate/detail/triangulate.h>
I get the following error messages, which all refer to the Boost Geometry modules. I removed the prefixes on the directory names to hopefully reduce clutter.
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(90,10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(90,20): error C2059: syntax error: 'constant'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(91,59): error C2065: 'PG': undeclared identifier
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(91,47): error C2974: 'boost::geometry::strategy::centroid::average': invalid template argument for 'Ignored1', type expected
.\boost\libs\geometry\include\boost\geometry\strategies\cartesian\centroid_average.hpp(51): message : see declaration of 'boost::geometry::strategy::centroid::average'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(91,47): error C2923: 'boost::geometry::strategy::centroid::average': 'PG' is not a valid template type argument for parameter 'Ignored2'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(91): message : see declaration of 'PG'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(91,47): error C3203: 'average': unspecialized class template can't be used as a template argument for template parameter 'Strategy', expected a real type
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(92,1): error C2906: 'boost::geometry::strategies::centroid::services::strategy_converter<int>': explicit specialization requires 'template <>'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(99,10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(99,20): error C2059: syntax error: 'constant'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(100,67): error C2065: 'PG': undeclared identifier
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(100,47): error C2974: 'boost::geometry::strategy::centroid::weighted_length': invalid template argument for 'Ignored1', type expected
.\boost\libs\geometry\include\boost\geometry\strategies\cartesian\centroid_weighted_length.hpp(49): message : see declaration of 'boost::geometry::strategy::centroid::weighted_length'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(100,47): error C2923: 'boost::geometry::strategy::centroid::weighted_length': 'PG' is not a valid template type argument for parameter 'Ignored2'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(100): message : see declaration of 'PG'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(100,47): error C2976: 'boost::geometry::strategy::centroid::weighted_length': too few template arguments
.\boost\libs\geometry\include\boost\geometry\strategies\cartesian\centroid_weighted_length.hpp(49): message : see declaration of 'boost::geometry::strategy::centroid::weighted_length'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(100,47): error C3203: 'weighted_length': unspecialized class template can't be used as a template argument for template parameter 'Strategy', expected a real type
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(101,1): error C2906: 'boost::geometry::strategies::centroid::services::strategy_converter<int>': explicit specialization requires 'template <>'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(108,10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(108,20): error C2059: syntax error: 'constant'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(109,66): error C2065: 'PG': undeclared identifier
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(109,70): error C2065: 'CT': undeclared identifier
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(109,47): error C2974: 'boost::geometry::strategy::centroid::bashein_detmer': invalid template argument for 'Ignored1', type expected
.\boost\libs\geometry\include\boost\geometry\strategies\cartesian\centroid_bashein_detmer.hpp(126): message : see declaration of 'boost::geometry::strategy::centroid::bashein_detmer'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(109,47): error C2923: 'boost::geometry::strategy::centroid::bashein_detmer': 'PG' is not a valid template type argument for parameter 'Ignored2'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(109): message : see declaration of 'PG'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(109,47): error C2923: 'boost::geometry::strategy::centroid::bashein_detmer': 'CT' is not a valid template type argument for parameter 'CalculationType'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(109): message : see declaration of 'CT'
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(109,47): error C3203: 'bashein_detmer': unspecialized class template can't be used as a template argument for template parameter 'Strategy', expected a real type
.\boost\libs\geometry\include\boost\geometry\strategies\centroid\cartesian.hpp(110,1): error C2906: 'boost::geometry::strategies::centroid::services::strategy_converter<int>': explicit specialization requires 'template <>'
Any suggestions would be helpful.
TIA
I was able to solve this problem and compile the program.
I stripped my main program down to the function that was giving me problems, deleted all of the header files, and started adding them back until I was able to resolve all of the variables. I still had build errors. Along the way, I saw a suggestion to add the following variable _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH to the pre-processor. This allowed the stripped-down program to compile.
I then reverted back to the main program, removed all of the header files and replaced them with the ones from the test program. This worked!
Here are the updated header files:
// Boost Codes
#include <vector>
#include <xmscore/stl/vector.h>
#include <xmscore/points/ptsfwd.h>
#include <xmscore/misc/base_macros.h>
#include <xmscore/misc/boost_defines.h>
#include <xmscore/misc/Observer.h>
#include <xmscore/misc/XmError.h>
// 2. My own header
#include <xmsgrid/triangulate/TrTriangulatorPoints.h>
// 3. Standard library headers
// 4. External library headers
// 5. Shared code headers
#include <xmsgrid/geometry/geoms.h>
#include <xmsgrid/geometry/GmPtSearch.h>
#include <xmsgrid/geometry/GmTriSearch.h>
#include <xmsgrid/triangulate/triangles.h>
#include <xmsgrid/triangulate/TrTriangulatorPoints.t.h>
#include <xmsgrid/triangulate/detail/triangulate.h>
//#include <xmscore/testing/TestTools.h>
#include <xmsinterp/tutorial/TutInterpolation.t.h>
#include <xmsinterp/interpolate/detail/NodalFunc.h>
#include <xmsinterp/interpolate/detail/InterpNatNeigh.h>
#include <xmsinterp/interpolate/detail/InterpCt.h>
#include <xmsinterp/interpolate/InterpIdw.h>
#include <xmsinterp/interpolate/InterpLinear.h>
#include <xmsinterp/interpolate/InterpAnisotropic.h>
using namespace xms;

Why is my class object causing undeclared identifier errors?

I am writing a program on Microsoft Visual C++ 2010 Express and am having an issue with my class object. I keep getting undeclared identifier and missing ';' before identifier errors and I'm not sure what is causing the problem.
I've checked my headers for any mistakes and have made several changes to see if it would fix the problem with no luck.
// RightJust class declaration that right justifies the numbers.
#ifdef RIGHTJUST_H_
#define RIGHTJUST_H_
#include "stdafx.h"
#include <iostream>
#include <string>
#include <cstring>
using namespace System;
using namespace std;
class RightJust
{
private:
int x, totalWH1, totalWH2, totalWH3, totalWH4;
int itemT1, itemT2, itemT3, itemT4, itemT5; // Holds item totals
string WH1, WH2, WH3, WH4;
int num[4][5]; // Array containing data
public:
RightJust();
int warehouseLen();
void rightJustZero();
void rightJustLess();
};
// This program asks to user to choose a report type and displays
// the report type chosen.
#include "stdafx.h"
#include <iostream>
#include "RightJust.h"
#include <string>
#include <cstring>
using namespace System;
using namespace std;
int main
{
RightJust type;
if(reportType == 1)
{
type.rightJustZero();
}
else if(reportType == 2)
{
type.rightJustLess();
}
}
I just want a solution to get rid of all the error messages to see if my program is working how I needed it to work.
Test3.cpp
1>Test3.cpp(24): error C2065: 'RightJust' : undeclared identifier
1>Test3.cpp(24): error C2146: syntax error : missing ';' before identifier 'type'
1>Test3.cpp(24): error C2065: 'type' : undeclared identifier
1>Test3.cpp(27): error C2065: 'type' : undeclared identifier
1>Test3.cpp(27): error C2228: left of '.rightJustZero' must have class/struct/union
1> type is ''unknown-type''
1>Test3.cpp(31): error C2065: 'type' : undeclared identifier
1>Test3.cpp(31): error C2228: left of '.rightJustLess' must have class/struct/union
1> type is ''unknown-type''
The include guard in your header is wrong. It should be
#ifndef RIGHTJUST_H_
Using #ifdef RIGHTJUST_H_ will skip the code if the symbol is not defined.
You should not have #include "stdafx.h" in your .h files. And since you seem to be using Visual Studio, you can just use #pragma once instead of the include guard.

Cannot include std::thread header in wxWidgets application

I have the following code:
#include "wx\wx.h"
class BClient : public wxApp
{
virtual bool OnInit();
virtual int OnQuit();
};
IMPLEMENT_APP(BClient)
bool BClient::OnInit()
{
return true;
}
int BClient::OnQuit()
{
return 0;
}
As soon I try to add the line
#include <thread>
I receive this errors:
Error 10 error C2347: '__w64' : can not be used with type '__w64
unsigned __int64'
Error 12 error C2143: syntax error : missing ';' before ','
Error 13 error C2059: syntax error : ','
The errors refer to this file: c:\program files (x86)\microsoft visual studio 12.0\vc\include\concrt.h
So, for some reason, wxwidgets and std::thread doesn't mix together.
Can someone explain to me why this is happening and is there a workaround for this issue ?
Thanks.
Something is wrong with your MSVS installation. Here, adding #include <thread> line either before or after #include <wx/wx.h> one works without any problems.
Also, on a completely unrelated note, there is no OnQuit() in the base class, only OnExit().

Visual studio errors in compiling

I keep getting the 2 errors listed below for the line that I have also included below, can someone please tell me why?
Error 1 error C2143: syntax error : missing ';' before '<'
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Line:
deque; <string> get_image_filename_list(string foldername);
First of all, try to include header at the beggining of your source file:
#include <deque>
#include <string>
using namespace std;
Then, try to modify your line like:
deque<string> get_image_filename_list(string foldername);

Visual C++ 2013 & error C2065: 'complex' : undeclared identifier & error C2059: syntax error : ','

#include "stdafx.h"
#include "stdio.h"
#include <iostream>
#include "math.h"
#include <complex>
#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
#include <io.h>
void multiple(complex**,complex*,complex*);
void solve(complex**, complex*, complex*, int);
As I typed the above-mentioned code, we receive the following errors:
error C2065: 'complex' : undeclared identifier
error C2059: syntax error : ','
Many thanks for your time,
The class is located in the namespace std as well as all other C++ standard library classes / functions. So you have to change complex to std::complex<T> (don't forget the template parameter!).