Problem compiling IDL created with OleView - idl

To correct a problem with the name of the value for the enum, after searching, that I need to modify the TLB file of my DLL. The first step that I need to do is to create the IDL file. So I use Oleview to create the file. Before doing the modification I to correct my problem, I decided to try and compile the IDL file. This gave me the error:
error MIDL2025 : syntax error : expecting a type specification near "AzEnumParameters"
After searching for the problem, I found this question was the way to correct the error. So I change the enum defitions of place and now I'm getting this error:
error MIDL2025 : syntax error : expecting a constant expression near "<"
error MIDL2035 : constant expression expected
error MIDL2025 : syntax error : expecting ) near "IUnknown"
I've got no idea what cause the error since I only inverted my enum definition and the functions defitions. What is causing the last errors in my file?
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: AccessParam.tlb
[
uuid(C24F6EAB-4957-34BB-8008-CCABAF1E8B36),
version(6.0),
custom(90883F05-3D28-11D2-8F17-00A0C9A6186D, "AccessParam, Version=6.0.5.0, Culture=neutral, PublicKeyToken=null")
]
library AccessParam
{
// TLib : // TLib : mscorlib.dll : {BED7F4EA-1A96-11D2-8F08-00A0C9A6186D}
importlib("mscorlib.tlb");
// TLib : Esri System Object Library 10.1 : {5E1F7BC3-67C5-4AEE-8EC6-C4B73AAC42ED}
importlib("esriSystem.olb");
// TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");
// Forward declare all types defined in this typelib
interface _AccessParameter;
interface _ManageParameter;
[
uuid(388AB2D9-A3A3-3400-8644-F0A3BA43F621),
version(1.0),
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "AccessParam.AccessParameter")
]
coclass AccessParameter {
interface _Object;
[default] interface _AccessParameter;
};
typedef [uuid(B59B449B-2757-3E69-A39A-4535A59CD173), version(1.0) ,
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "AccessParam.AccessParameter+AzEnumGDBNames")
]
enum {
AzEnumGDBNames_AzGOcadastre = 0,
AzEnumGDBNames_AzGOhistorique = 1,
AzEnumGDBNames_AzGOtravail = 2,
AzEnumGDBNames_AzGOmatrice = 3,
AzEnumGDBNames_AzGOmatriceHab = 4,
AzEnumGDBNames_AzGOmatriceHis = 5
} AzEnumGDBNames;
typedef [uuid(94C28066-95C8-3380-A46A-DFECD219E900), version(1.0) ,
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "AccessParam.AccessParameter+AzEnumParameters")
]
enum {
AzEnumParameters_AzConnection = 0,
AzEnumParameters_AzFuseau = 1,
AzEnumParameters_AzRepPrinc = 2,
AzEnumParameters_AzSuffixeGDB = 3,
AzEnumParameters_AzListMuni = 4,
AzEnumParameters_AzRepGDB = 5,
AzEnumParameters_AzRepDataMRN = 6,
AzEnumParameters_AzRepRapport = 7,
AzEnumParameters_AzRepRoleFoncier = 8,
AzEnumParameters_AzRepMatriceScan = 9,
AzEnumParameters_AzRepArchives = 10
} AzEnumParameters;
[
odl,
uuid(3CEEDD8D-2A91-3BCB-A620-1D818994EF47),
version(1.0),
dual,
oleautomation,
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "AccessParam.AccessParameter+_AccessParameter")
]
interface _AccessParameter : IDispatch {
[id(0x00000001), propget]
HRESULT NomTerritoire([out, retval] BSTR* pRetVal);
[id(0x00000001), propput]
HRESULT NomTerritoire([in] BSTR pRetVal);
[id(0x00000002), propget]
HRESULT AliasTerritoire([out, retval] BSTR* pRetVal);
[id(0x00000002), propput]
HRESULT AliasTerritoire([in] BSTR pRetVal);
[id(0x00000003), propget]
HRESULT NomAppli([out, retval] BSTR* pRetVal);
[id(0x00000003), propput]
HRESULT NomAppli([in] BSTR pRetVal);
[id(0x00000004), propget]
HRESULT DateCreate([out, retval] DATE* pRetVal);
[id(0x00000004), propput]
HRESULT DateCreate([in] DATE pRetVal);
[id(0x00000005), propget]
HRESULT CountParam([out, retval] short* pRetVal);
[id(0x00000006), propget]
HRESULT ToCreate([out, retval] VARIANT_BOOL* pRetVal);
[id(0x00000006), propput]
HRESULT ToCreate([in] VARIANT_BOOL pRetVal);
[id(0x00000007), propget]
HRESULT CodeParam(
[in] short Index,
[out, retval] AzEnumParameters* pRetVal);
[id(0x00000007), propput]
HRESULT CodeParam(
[in] short Index,
[in] AzEnumParameters pRetVal);
[id(0x00000008), propget]
HRESULT ValueParam(
[in] AzEnumParameters EnumP,
[out, retval] BSTR* pRetVal);
[id(0x00000008), propput]
HRESULT ValueParam(
[in] AzEnumParameters EnumP,
[in] BSTR pRetVal);
[id(0x00000009), propget]
HRESULT DescripParam(
[in] AzEnumParameters EnumP,
[out, retval] BSTR* pRetVal);
[id(0x00000009), propput]
HRESULT DescripParam(
[in] AzEnumParameters EnumP,
[in] BSTR pRetVal);
[id(0x0000000a), propget]
HRESULT EstModifParam(
[in] AzEnumParameters EnumP,
[out, retval] VARIANT_BOOL* pRetVal);
[id(0x0000000a), propput]
HRESULT EstModifParam(
[in] AzEnumParameters EnumP,
[in] VARIANT_BOOL pRetVal);
[id(0x0000000b), propget]
HRESULT GetPropertyConnect(
[in] AzEnumGDBNames GDB,
[out, retval] IPropertySet** pRetVal);
[id(0x0000000c), propget]
HRESULT NameGDB(
[in] AzEnumGDBNames EnumGDB,
[out, retval] BSTR* pRetVal);
};
[
uuid(25E50774-0A09-3C1B-A7DA-FBFE54CBFBC9),
version(1.0),
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "AccessParam.ManageParameter")
]
coclass ManageParameter {
interface _Object;
[default] interface _ManageParameter;
};
typedef [uuid(5ED0622E-5DC6-3DF6-A568-57DF774744F1), version(1.0) ,
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "AccessParam.ManageParameter+AzEnumAppNames")
]
enum {
AzEnumAppNames_AzAppGOcadastre = 0,
AzEnumAppNames_AzAppGOmatrice = 1
} AzEnumAppNames;
[
odl,
uuid(7D8D41B4-EF0A-370B-86BB-163F1A27B568),
version(1.0),
dual,
oleautomation,
custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "AccessParam.ManageParameter+_ManageParameter")
]
interface _ManageParameter : IDispatch {
[id(0x00000001), propget]
HRESULT LoadParam(
[in, optional, defaultvalue(<unprintable IUnknown*>)] VARIANT Index,
[in, optional, defaultvalue(0)] AzEnumAppNames GOapp,
[out, retval] _AccessParameter** pRetVal);
[id(0x00000002), propget]
HRESULT LoadParamDefault(
[in] BSTR NomApp,
[out, retval] _AccessParameter** pRetVal);
[id(0x00000003), propget]
HRESULT GetParamMuni(
[in] short Index,
[out, retval] _AccessParameter** pRetVal);
[id(0x00000004), propget]
HRESULT Count([out, retval] short* pRetVal);
[id(0x00000005)]
HRESULT AddTerritoire([in] _AccessParameter* Param);
[id(0x00000006)]
HRESULT SuppTerritoire(
[in, out] BSTR* Terr,
[in, out] BSTR* Appli);
[id(0x00000007)]
HRESULT UpdateAllMuni();
[id(0x00000008)]
HRESULT UpdateMuni([in, out] short* Index);
};
};

Found the problem. In the declaration
HRESULT LoadParam(
[in, optional, defaultvalue(<unprintable IUnknown*>)] VARIANT Index,
[in, optional, defaultvalue(0)] AzEnumAppNames GOapp,
[out, retval] _AccessParameter** pRetVal);
The unprintable IUnknown* was causing the error. I remove the defaultvalue declaration for the index field and everything compile.

Related

QtXml/qdom.h proplems in a qt project

I'm using CGAL , libQGLViewer libraries in a project on QT creator , Fedora 27
but it shows errors on the header file of the libraries
Compile output:
/usr/include/QtXml/qdom.h:99:20: error: variable ‘Q_XML_EXPORT QDomImplementation’ has initializer but incomplete type
class Q_XML_EXPORT QDomImplementation
^~~~~~~~~~~~~~~~~~
/usr/include/QtXml/qdom.h:101:1: error: expected primary-expression before ‘public’
public:
^~~~~~
/usr/include/QtXml/qdom.h:101:1: error: expected ‘}’ before ‘public’
/usr/include/QtXml/qdom.h:101:1: error: expected ‘,’ or ‘;’ before ‘public’
/usr/include/QtXml/qdom.h:103:30: error: ‘QDomImplementation’ does not name a type
QDomImplementation(const QDomImplementation&);
^~~~~~~~~~~~~~~~~~
/usr/include/QtXml/qdom.h:103:50: error: expected constructor, destructor, or type conversion before ‘;’ token
QDomImplementation(const QDomImplementation&);
^
/usr/include/QtXml/qdom.h:104:26: error: expected constructor, destructor, or type conversion before ‘;’ token
~QDomImplementation();
^
/usr/include/QtXml/qdom.h:105:5: error: ‘QDomImplementation’ does not name a type
QDomImplementation& operator= (const QDomImplementation&);
^~~~~~~~~~~~~~~~~~
/usr/include/QtXml/qdom.h:106:28: error: ‘QDomImplementation’ does not name a type
bool operator== (const QDomImplementation&) const;
^~~~~~~~~~~~~~~~~~
/usr/include/QtXml/qdom.h:106:49: error: non-member function ‘bool operator==(const int&)’ cannot have cv-qualifier
bool operator== (const QDomImplementation&) const;
^~~~~
/usr/include/QtXml/qdom.h:106:49: error: ‘bool operator==(const int&)’ must have an argument of class or enumerated type
/usr/include/QtXml/qdom.h:107:28: error: ‘QDomImplementation’ does not name a type
bool operator!= (const QDomImplementation&) const;
^~~~~~~~~~~~~~~~~~
/usr/include/QtXml/qdom.h:107:49: error: non-member function ‘bool operator!=(const int&)’ cannot have cv-qualifier
bool operator!= (const QDomImplementation&) const;
^~~~~
/usr/include/QtXml/qdom.h:107:49: error: ‘bool operator!=(const int&)’ must have an argument of class or enumerated type
/usr/include/QtXml/qdom.h:110:69: error: non-member function ‘bool hasFeature(const QString&, const QString&)’ cannot have cv-qualifier
bool hasFeature(const QString& feature, const QString& version) const;
^~~~~
/usr/include/QtXml/qdom.h:121:1: error: expected unqualified-id before ‘private’
private:
^~~~~~~
/usr/include/QtXml/qdom.h:123:51: error: expected constructor, destructor, or type conversion before ‘;’ token
QDomImplementation(QDomImplementationPrivate*);
^
/usr/include/QtXml/qdom.h:125:5: error: ‘friend’ used outside of class
friend class QDomDocument;
^~~~~~
/usr/include/QtXml/qdom.h:126:1: error: expected declaration before ‘}’ token
};
all errors appear in QtXml/qdom.h file , I have no idea how to solve them
I appreciate any help,
thanks

Compiling fails, D programming (GDC)

So I have installed gdc trying to do a simple compile at command prompt. Not sure if my imports\includes actually work? What should I do? I am 100% sure the program compiles with Eclipse\dub\dtt\ldc...
*C:\Development\gdc\bin>x86_64-unknown-linux-gnu-gdc C:\Users\plann\Downloads\test\MessageApp\src\app.d --sysroot=C:\Development\gdc\sysroot -B "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib"
C:\Users\plann\Downloads\test\MessageApp\src\app.d:13:7: error: undefined identifier 'DWORD'
DWORD bakgrunfar = 0;
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:14:7: error: undefined identifier 'DWORD'
DWORD textfar = 0;
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:17:7: error: undefined identifier 'HFONT'
HFONT hFont, hOldFont;
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:17:14: error: undefined identifier 'HFONT'
HFONT hFont, hOldFont;
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:20:5: error: undefined identifier 'HWND'
int WindowProcedure (HWND, UINT, WPARAM, LPARAM );
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:20:5: error: undefined identifier 'UINT'
int WindowProcedure (HWND, UINT, WPARAM, LPARAM );
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:20:5: error: undefined identifier 'WPARAM'
int WindowProcedure (HWND, UINT, WPARAM, LPARAM );
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:20:5: error: undefined identifier 'LPARAM'
int WindowProcedure (HWND, UINT, WPARAM, LPARAM );
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:23:5: error: undefined identifier 'HINSTANCE'
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:23:5: error: undefined identifier 'HINSTANCE'
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:23:5: error: undefined identifier 'LPSTR'
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:44:5: error: undefined identifier 'HINSTANCE'
int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:44:5: error: undefined identifier 'HINSTANCE'
int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:44:5: error: undefined identifier 'LPSTR'
int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:99:5: error: undefined identifier 'HWND'
int WindowProcedure(HWND hwnd, UINT AEX, WPARAM wParam, LPARAM lParam) nothrow
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:99:5: error: undefined identifier 'UINT'
int WindowProcedure(HWND hwnd, UINT AEX, WPARAM wParam, LPARAM lParam) nothrow
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:99:5: error: undefined identifier 'WPARAM'
int WindowProcedure(HWND hwnd, UINT AEX, WPARAM wParam, LPARAM lParam) nothrow
^
C:\Users\plann\Downloads\test\MessageApp\src\app.d:99:5: error: undefined identifier 'LPARAM'
int WindowProcedure(HWND hwnd, UINT AEX, WPARAM wParam, LPARAM lParam) nothrow*
We cannot help without taking a look at the app.d. From the errors it seems that you did not import windows module that defines the various Windows-specific types.. Start with the following two typical imports:
import core.runtime;
import core.sys.windows.windows;
I strongly suggest you reading the following guide: https://wiki.dlang.org/D_for_Win32

pcl_visualizer.h - fatal error LNK1120: 1 unresolved externals

error LNK2001: unresolved external symbol "public: virtual void __cdecl pcl::visualization::PCLVisualizer::FPSCallback::Execute(class vtkObject *,unsigned long,void *)" (?Execute#FPSCallback#PCLVisualizer#visualization#pcl##UEAAXPEAVvtkObject##KPEAX#Z)
1>C:\Users\hatea\Documents\Visual Studio 2015\Projects\PCLTester\x64\Debug\PCLTester.dll : fatal error LNK1120: 1 unresolved externals
I have thoroughly exhausted all avenues dealing with this issue. I checked here, and I found a similar question/answer series: error LNK2001 when including "pcl_visualizer.h"
The problem is that I do not want to comment out the FPSCallback method. I need it for the VTK visualizer I am using. I have determined that I only receive the unresolved external error when I reference the .h file in a managed C++/CLI library.
#pragma once
#pragma unmanaged
#include <pcl/visualization/pcl_visualizer.h>
#pragma managed
using namespace System;
namespace PCLTesterCLI
{
public ref class PCLTesterCLI
{
public:
PCLTesterCLI();
virtual ~PCLTesterCLI();
};
}
If I do the same in an unmanaged Win32 library, the library is successfully built.
#pragma once
#include <pcl/visualization/pcl_visualizer.h>
class PCLTester
{
public:
PCLTester();
virtual ~PCLTester();
};
Here is the segment from pcl_visualizer.h:
struct FPSCallback : public vtkCommand
{
static FPSCallback *New () { return (new FPSCallback); }
FPSCallback () : actor (), pcl_visualizer (), decimated () {}
FPSCallback (const FPSCallback& src) : vtkCommand (), actor (src.actor), pcl_visualizer (src.pcl_visualizer), decimated (src.decimated) {}
FPSCallback& operator = (const FPSCallback& src) { actor = src.actor; pcl_visualizer = src.pcl_visualizer; decimated = src.decimated; return (*this); }
virtual void
Execute (vtkObject*, unsigned long event_id, void*);
vtkTextActor *actor;
PCLVisualizer* pcl_visualizer;
bool decimated;
};
/** \brief The FPSCallback object for the current visualizer. */
vtkSmartPointer<FPSCallback> update_fps_;
Here is the segment from pcl_visualizer.cpp:
void
pcl::visualization::PCLVisualizer::FPSCallback::Execute (
vtkObject* caller, unsigned long, void*)
{
vtkRenderer *ren = reinterpret_cast<vtkRenderer *> (caller);
float fps = 1.0f / static_cast<float> (ren->GetLastRenderTimeInSeconds ());
char buf[128];
sprintf (buf, "%.1f FPS", fps);
actor->SetInput (buf);
}
Any ideas why the structure and member function conflict in a managed environment?
The reason that my question is unique is that my symbols error was not a result of anything I did: e.g. declaring a function without defining it, having a syntax error that results in the function not being properly defined, or leaving out a .lib dependency from Linker->Input. In my case, I have all the correct .lib files linked and the function from pcl::visualization seems well defined. For some strange reason, it is still being missed at compile time in the managed library. I copied my dependencies from my managed .vcxproj to my unmanaged .vcxproj to verify that it was not a dependency issue. Both classes are setup with the minimum class requirements to prevent conflicts in that regard. Both projects have the same .h file and .lib files linked.
Interestingly, I solved this issue by placing the pcl_visualizer code into my managed c++ code at the top. I had to add a header as well:
#include <vtkTextActor.h>
void
pcl::visualization::PCLVisualizer::FPSCallback::Execute(vtkObject* caller, unsigned long, void*)
{
vtkRenderer *ren = reinterpret_cast<vtkRenderer *> (caller);
float fps = 1.0f / static_cast<float> (ren->GetLastRenderTimeInSeconds());
char buf[128];
sprintf(buf, "%.1f FPS", fps);
actor->SetInput(buf);
}
The other option is to go into pcl_visualizer.h and comment out the offending line (I do not know why this line causes issues, but I narrowed it down to this, and my vtk visualizer still works!):
//FPSCallback (const FPSCallback& src) : vtkCommand (), actor (src.actor), pcl_visualizer (src.pcl_visualizer), decimated (src.decimated) {}
The code then looks like:
struct FPSCallback : public vtkCommand
{
static FPSCallback *New () { return (new FPSCallback); }
FPSCallback () : actor (), pcl_visualizer (), decimated () {}
//FPSCallback (const FPSCallback& src) : vtkCommand (), actor (src.actor), pcl_visualizer (src.pcl_visualizer), decimated (src.decimated) {}
FPSCallback& operator = (const FPSCallback& src) { actor = src.actor; pcl_visualizer = src.pcl_visualizer; decimated = src.decimated; return (*this); }
virtual void
Execute (vtkObject*, unsigned long event_id, void*);
vtkTextActor *actor;
PCLVisualizer* pcl_visualizer;
bool decimated;
};
/** \brief The FPSCallback object for the current visualizer. */
vtkSmartPointer<FPSCallback> update_fps_;

How can I insert in a multimap of maps?

How can I insert element in the following map?
map<Longitud,multimap<Latitud, ID> > posicionGeo;
I tried to insert like this:
posicionGeo.insert(make_pair(x.getLongitude(),make_pair(x.getLatitude(),x.getID())));
but this isn't working. Throws this error:
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:64:0,
from /usr/include/c++/4.8/bits/char_traits.h:39,
from /usr/include/c++/4.8/string:40,
from fecha.h:9,
from principal.cpp:2:
/usr/include/c++/4.8/bits/stl_pair.h: In instantiation of ‘std::pair<_T1, _T2>::pair(const std::pair<_U1, _U2>&) [with _U1 = int; _U2 = std::pair<int, int>; _T1 = const float; _T2 = std::multimap<float, unsigned int>]’:
CrimeSearch.hxx:33:51: required from here
/usr/include/c++/4.8/bits/stl_pair.h:119:39: error: no matching function for call to ‘std::multimap<float, unsigned int>::multimap(const std::pair<int, int>&)’
: first(__p.first), second(__p.second) { }
^
/usr/include/c++/4.8/bits/stl_pair.h:119:39: note: candidates are:
In file included from /usr/include/c++/4.8/map:62:0,
from CrimeSearch.h:9,
from principal.cpp:4:
/usr/include/c++/4.8/bits/stl_multimap.h:235:9: note: template<class _InputIterator> std::multimap<_Key, _Tp, _Compare, _Alloc>::multimap(_InputIterator, _InputIterator, const _Compare&, const allocator_type&)
multimap(_InputIterator __first, _InputIterator __last,
^
/usr/include/c++/4.8/bits/stl_multimap.h:235:9: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:64:0,
from /usr/include/c++/4.8/bits/char_traits.h:39,
from /usr/include/c++/4.8/string:40,
from fecha.h:9,
from principal.cpp:2:
/usr/include/c++/4.8/bits/stl_pair.h:119:39: note: candidate expects 4 arguments, 1 provided
: first(__p.first), second(__p.second) { }
^
In file included from /usr/include/c++/4.8/map:62:0,
from CrimeSearch.h:9,
from principal.cpp:4:
/usr/include/c++/4.8/bits/stl_multimap.h:219:9: note: template<class _InputIterator> std::multimap<_Key, _Tp, _Compare, _Alloc>::multimap(_InputIterator, _InputIterator)
multimap(_InputIterator __first, _InputIterator __last)
^
/usr/include/c++/4.8/bits/stl_multimap.h:219:9: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:64:0,
from /usr/include/c++/4.8/bits/char_traits.h:39,
from /usr/include/c++/4.8/string:40,
from fecha.h:9,
from principal.cpp:2:
/usr/include/c++/4.8/bits/stl_pair.h:119:39: note: candidate expects 2 arguments, 1 provided
: first(__p.first), second(__p.second) { }
^
In file included from /usr/include/c++/4.8/map:62:0,
from CrimeSearch.h:9,
from principal.cpp:4:
/usr/include/c++/4.8/bits/stl_multimap.h:177:7: note: std::multimap<_Key, _Tp, _Compare, _Alloc>::multimap(const std::multimap<_Key, _Tp, _Compare, _Alloc>&) [with _Key = float; _Tp = unsigned int; _Compare = std::less<float>; _Alloc = std::allocator<std::pair<const float, unsigned int> >]
multimap(const multimap& __x)
^
/usr/include/c++/4.8/bits/stl_multimap.h:177:7: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘const std::multimap<float, unsigned int>&’
/usr/include/c++/4.8/bits/stl_multimap.h:166:7: note: std::multimap<_Key, _Tp, _Compare, _Alloc>::multimap(const _Compare&, const allocator_type&) [with _Key = float; _Tp = unsigned int; _Compare = std::less<float>; _Alloc = std::allocator<std::pair<const float, unsigned int> >; std::multimap<_Key, _Tp, _Compare, _Alloc>::allocator_type = std::allocator<std::pair<const float, unsigned int> >]
multimap(const _Compare& __comp,
^
/usr/include/c++/4.8/bits/stl_multimap.h:166:7: note: no known conversion for argument 1 from ‘const std::pair<int, int>’ to ‘const std::less<float>&’
/usr/include/c++/4.8/bits/stl_multimap.h:157:7: note: std::multimap<_Key, _Tp, _Compare, _Alloc>::multimap() [with _Key = float; _Tp = unsigned int; _Compare = std::less<float>; _Alloc = std::allocator<std::pair<const float, unsigned int> >]
multimap()
^
/usr/include/c++/4.8/bits/stl_multimap.h:157:7: note: candidate expects 0 arguments, 1 provided
I find the solution, you can do the insert in two steps:
multimap<Latitud, ID> mymap;
mymap.insert(make_pair(x.getLatitude(),x.getID()));
posicionGeo.insert(make_pair(x.getLongitude(),mymap));
but i dont know why this:
posicionGeo.insert(make_pair(x.getLongitude(),make_pair(x.getLatitude(),x.getID())));
dont work, i think that is the same.

serializing union type via custom function: "static assertion failed:: typex::value"

I am serializing the cl_long2 type from OpenCL which is defined like this (simplified from /usr/include/CL/cl_platform.hpp):
typedef int64_t cl_long;
typedef union
{
cl_long __attribute__ ((aligned(16))) s[2];
struct{ cl_long x, y; };
struct{ cl_long s0, s1; };
struct{ cl_long lo, hi; };
} cl_long2;
I defined the following stand-alone serialization function:
namespace boost{ namespace serialization {
template<class Archive> void serialize(Archive &ar, cl_long2 &i, const unsigned version){
ar & make_nvp("x",i.x);
ar & make_nvp("y",i.y);
}
}};
When I compile my code, which invokes a serialization of cl_long2 from as a class member, I am getting the following error, which I cannot understand (the error is the same if it is not a std::vector<cl_long2>, just a stand-alone variable):
/usr/include/boost/archive/detail/check.hpp: In function ‘void boost::archive::detail::check_object_level() [with T = cl_long2]’:
/usr/include/boost/archive/detail/iserializer.hpp:438:9: instantiated from ‘static void boost::archive::detail::load_non_pointer_type<Archive>::invoke(Archive&, T&) [with T = cl_long2, Archive = boost::archive::xml_iarchive]’
/usr/include/boost/archive/detail/iserializer.hpp:592:5: instantiated from ‘void boost::archive::load(Archive&, T&) [with Archive = boost::archive::xml_iarchive, T = cl_long2]’
/usr/include/boost/archive/detail/common_iarchive.hpp:66:9: instantiated from ‘void boost::archive::detail::common_iarchive<Archive>::load_override(T&, int) [with T = cl_long2, Archive = boost::archive::xml_iarchive]’
/usr/include/boost/archive/basic_xml_iarchive.hpp:86:9: instantiated from ‘void boost::archive::basic_xml_iarchive<Archive>::load_override(const boost::serialization::nvp<T>&, int) [with T = cl_long2, Archive = boost::archive::xml_iarchive]’
/usr/include/boost/archive/xml_iarchive.hpp:93:9: instantiated from ‘void boost::archive::xml_iarchive_impl<Archive>::load_override(T&, int) [with T = const boost::serialization::nvp<cl_long2>, Archive = boost::archive::xml_iarchive]’
/usr/include/boost/archive/detail/interface_iarchive.hpp:60:9: [ skipping 5 instantiation contexts ]
/usr/include/boost/serialization/split_free.hpp:58:9: instantiated from ‘static void boost::serialization::free_loader<Archive, T>::invoke(Archive&, T&, unsigned int) [with Archive = boost::archive::xml_iarchive, T = std::vector<cl_long2>]’
/usr/include/boost/serialization/split_free.hpp:74:5: instantiated from ‘void boost::serialization::split_free(Archive&, T&, unsigned int) [with Archive = boost::archive::xml_iarchive, T = std::vector<cl_long2>]’
/usr/include/boost/serialization/vector.hpp:151:5: instantiated from ‘void boost::serialization::serialize(Archive&, std::vector<U, Allocator>&, unsigned int) [with Archive = boost::archive::xml_iarchive, U = cl_long2, Allocator = std::allocator<cl_long2>]’
/usr/include/boost/serialization/serialization.hpp:128:9: instantiated from ‘void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::xml_iarchive, T = std::vector<cl_long2>]’
/usr/include/boost/archive/detail/iserializer.hpp:188:5: instantiated from ‘void boost::archive::detail::iserializer<Archive, T>::load_object_data(boost::archive::detail::basic_iarchive&, void*, unsigned int) const [with Archive = boost::archive::xml_iarchive, T = std::vector<cl_long2>]’
myFile.cpp:368:2: instantiated from here
/usr/include/boost/archive/detail/check.hpp:60:5: error: static assertion failed: "typex::value"
The same error appears regardless of whether the archive type is xml or binary. I am using boost::serialization 1.46.
Any hints?
**EDIT: A smaller example including error is at http://ideone.com/4UgCn
If you look at the line where the assertion fails (detail/check.hpp:60), there is a comment right above it:
// trap attempts to serialize objects marked
// not_serializable
BOOST_STATIC_ASSERT(typex::value);
The documentation of this 'not_serializable' trait says that you have to enable this long2 type first. As you found out, this is done by:
BOOST_CLASS_IMPLEMENTATION(long2,boost::serialization::object_serializable)

Resources