Insertion/Use of boost::multi_index - new thread
Hi,
When I try to create a object of this,
typedef boost::multi_index_container<
ClassX*, //mapped value
boost::multi_index::indexed_by< //list of indices
boost::multi_index::hashed_unique<
boost::multi_index::const_mem_fun
, boost::multi_index::hashed_unique< boost::multi_index::const_mem_fun
//hashed index by unique Key1 ClassXMultiKeyIndexed;
like,
ClassXMultiKeyIndexed sample;
and insert a pointer like this,
ClassX *a;
ClassXMultiKeyIndexed sample;
//a is not NULL and is filled up before the below insert
sample.insert(a);
This is the compilation error, it compiles fine if "sample.insert(a)" is
commented out.
Compilation error :
Compiling...
stm_container_manager_abc.cpp
c:\code\common\lib\boost\boost\detail\allocator_utilities.hpp(153) : error
C2061: syntax error : identifier 'p'
c:\code\common\lib\boost\boost\multi_index\detail\index_base.hpp(105) : see
reference to function template instantiation 'void
boost::detail::allocator::construct
El 19/09/2016 a las 11:29, Ram escribió:
Hi,
When I try to create a object of this,
typedef boost::multi_index_container< ClassX*,//mapped value boost::multi_index::indexed_by/list of indices boost::multi_index::hashed_unique< boost::multi_index::const_mem_fun
//hashed index by unique Key1 , boost::multi_index::hashed_unique< boost::multi_index::const_mem_fun
//hashed index by unique Key1 ClassXMultiKeyIndexed;
like, ClassXMultiKeyIndexed sample;
and insert a pointer like this,
ClassX *a; ClassXMultiKeyIndexed sample;
//a is not NULL and is filled up before the below insert sample.insert(a);
This is the compilation error, it compiles fine if "sample.insert(a)" is commented out.
Compilation error :
Compiling... stm_container_manager_abc.cpp c:\code\common\lib\boost\boost\detail\allocator_utilities.hpp(153) : error C2061: syntax error : identifier 'p' c:\code\common\lib\boost\boost\multi_index\detail\index_base.hpp(105) : see reference to function template instantiation 'void boost::detail::allocator::construct
(void *,const Type &)' being compiled with [ Type=Container * ] [...]
The problem is not apparent to me from the contextual info you're providing, what I see seems basically correct but surely some detail is missing. A problem with your post is that you're providing a modified version of the real code (for instance, where you say ClassX your code is actually dealing with a class called Container) and information is probably lost in translation. I've turned your sample code into a complete test program: http://coliru.stacked-crooked.com/a/b63feba754f81f67 that compiles and run without problem. You might want to: 1. See if this same test program works OK in your environment. 2. Compare with your real code and try to spot a significant difference. 3. Turn your real code into a complete test program showing the error that the rest here at the list can check locally and investigate. Joaquín M López Muñoz
Hi Joaquin, Looks like this might be the problem, http://stackoverflow.com/questions/11150014/boostproperty-tree-compile-error... but doing that did not help me :( Any help would be appreciated. I too will try to do something and let you know if I succeed. Thanks, Ram
Could not figure out why inserting into a boost::multi_index container is creating a compilation issue that starts off with c:\code\common\lib\boost\boost\detail\allocator_utilities.hpp(153) : error C2061: syntax error : identifier 'p' and then a lot of errors.. I am compiling in Visual Studio 2005. Has anybody seen a similar problem? Thanks, Ram
El 20/09/2016 a las 11:33, Ram escribió:
Could not figure out why inserting into a boost::multi_index container is creating a compilation issue that starts off with
c:\code\common\lib\boost\boost\detail\allocator_utilities.hpp(153) : error C2061: syntax error : identifier 'p'
and then a lot of errors..
I am compiling in Visual Studio 2005.
Has anybody seen a similar problem?
Visual Studio 2005 (aka MSVC 8.0) is able to deal with Boost.MultiIndex as shown in http://www.boost.org/development/tests/master/developer/multi_index.html Other than this, you really need to provide more info in order for the community to be of any help. I suggested three routes you can decide to take to better understand the problem: 1. See if this test program works OK in your environment: http://coliru.stacked-crooked.com/a/b63feba754f81f67 2. Compare with your real code and try to spot a significant difference. 3. Turn your real code into a complete test program showing the error that the rest here at the list can check locally and investigate. I see you're also asking at Stack Overflow, where people have suggested a number of interesting things to try/see, but you have failed to provide any feedback on them. To be totally open, you can't expect others to magically know what your problem is without some additional effort on your side --well, you certainly can expect that, but I think you won't get anything. Joaquín M López Muñoz
Hi Joaquin, Thanks for your help! I tried creating a project and turned "Using precompiled headers to "Not using precompiled headers" and tried your code. That compiled! I think I should do that in my project too, will try that and let you know, but I am not sure I can do that in our official code. Will try that and let you know anyway. But thanks a lot for your help! My first real multi_index program worked! Thanks, Ram
Hi, It doesnt work even after I turn "Using precompiled headers to "Not using precompiled headers", now seeing if there is any difference between the two things and try to find out what the problem is. Thanks, Ram
Hi,
I simplified my problem to make sure it was not because of my class or
something like that, this is the exact content(related to
boost::multi_index) in the header file,
example.h
#include
int_multiset;
and then below it in the header file I have my class written,
as follows,
class MgrABC : public MainManager {
public:
int_multiset sample1;
<already existing code>
.
.
.
protected:
virtual void _handler();
<already existing code>
.
.
.
};
In the corresponding cpp file
example.cpp
void MgrABC::_handler() {
On 21/09/2016 16:58, Ram wrote:
I simplified my problem to make sure it was not because of my class or something like that, this is the exact content(related to boost::multi_index) in the header file, [...] c:\sample\common\lib\boost\boost\detail\allocator_utilities.hpp(153) : error C2061: syntax error : identifier 'p'
Do you have something that #defines new to something else? (It's not uncommon for old-school memory leak detectors and the like.) Try removing that.
We dont have new #defined to anything else, just to be safe we have a customNew that we use, that will only be called if we use "customNew". A call to new will only call new, nothing different will be called.. Thanks, Ram
Hi Joaquin, I hope the new complete code I gave is complete and verifiable on its own and people here can help. Struggling with this error for the last two days. Thanks, Ram
Hi,
Hope this is a clue, if I replace "this->sample1.insert(1);" to
"this->sample1.find(1);" it compiles fine.
Thanks,
Ram
On Wed, Sep 21, 2016 at 11:51 AM, Ram
Hi Joaquin,
I hope the new complete code I gave is complete and verifiable on its own and people here can help. Struggling with this error for the last two days.
Thanks, Ram
El 21/09/2016 a las 6:58, Ram escribió:
Hi, I simplified my problem to make sure it was not because of my class or something like that, this is the exact content(related to boost::multi_index) in the header file,
Hi, First of all, please follow this list's posting guidelines and do use inline replies after a small portion of the post you're replying to for context, just like I'm doing here and is explained at http://www.boost.org/community/policy.html#quoting Now to your question.
example.h
#include
#include #include [...]
In the corresponding cpp file example.cpp void MgrABC::_handler() {
. . . this->sample1.insert(1);
OK, let's try a couple of things: 1. Can you please fetch your local c:\sample\common\lib\boost\boost\detail\allocator_utilities.hpp file and send it back attached? 2. Where your testing code says this->sample1.insert(1); remove that statement and write the following: int x=0,y=0; boost::detail::allocator::construct(&x,y); What is the observed behavior on compilation? Joaquín M López Muñoz
Attached my allocator_utilities.hpp to this mail. When I tried replacing, this->sample1.insert(1); by, int x=0,y=0; boost::detail::allocator::construct(&x,y); this is the compilation output(changed the file name/directories in the previous example too), Compiling... example.cpp c:\sample\common\lib\boost\boost\detail\allocator_utilities.hpp(153) : error C2061: syntax error : identifier 'p' c:\sample\example.cpp(389) : see reference to function template instantiation 'void boost::detail::allocator::construct<int>(void *,const Type &)' being compiled with [ Type=int ] Build log was saved at "file://c:\sample\build\bin\sample\win\Debug\obj\BuildLog.htm" Sample - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Thanks, Ram
El 21/09/2016 a las 8:38, Ram escribió:
Attached my allocator_utilities.hpp to this mail.
Ram, Please do follow this list's posting guidelines and keep the formatting clear. I'll be happy to continue the discussion when you show some observance for the netiquette rules of the list. I've provided you with the link to the guidelines. Joaquín M López Muñoz
Hi Joaquin, I am not sure what I did wrong. I not been Top Quoting after you asked me to and I am trying to follow the guidelines. Not sure what I did wrong here. Thanks, Ram
On 21/09/2016 19:16, Ram wrote:
I am not sure what I did wrong. I not been Top Quoting after you asked me to and I am trying to follow the guidelines. Not sure what I did wrong here.
The problem is that you're not quoting at all. You should be inline quoting with minimal (but not zero) context, similar to this reply. If you're using Outlook, you should find a better email client, since it's very hard (though not completely impossible) to configure Outlook to do quoting any way other than top-posting.
[The problem is that you're not quoting at all. You should be inline quoting with minimal (but not zero) context, similar to this reply.] Will take care next time. Is this reply fine? -Ram
Hi Joaquin, [Please do follow this list's posting guidelines and keep the formatting clear] Will make sure I am clear about what I am speaking about(by quoting whats required). The my compilation output after the change to [ int x=0,y=0; boost::detail::allocator::construct(&x,y);] in allocator_utilities.hpp help? Thanks, Ram
El 21/09/2016 a las 13:58, Ram escribió:
Hi Joaquin,
[Please do follow this list's posting guidelines and keep the formatting clear]
Will make sure I am clear about what I am speaking about(by quoting whats required).
The my compilation output after the change to [ int x=0,y=0; boost::detail::allocator::construct(&x,y);]
in allocator_utilities.hpp help?
Yes, it shows that the problem seems not to be really connected to
Boost.MultiIndex.
My hunch is this is related to the precompiled header effect you talked
about some
posts ago, or that there's an evil macro affecting this very simple code.
In any case, please follow these steps so that we can narrow down the
problem:
1. Continuing with your example.cpp file, where you last inserted the
boost::detail::allocator::construct bit, please remove all usage of
Boost.MultiIndex
and its headers, and simply add this #include
#include
On Wed, Sep 21, 2016 at 4:56 PM, Joaquin M López Muñoz < joaquinlopezmunoz@gmail.com> wrote:
El 21/09/2016 a las 13:58, Ram escribió:
Yes, it shows that the problem seems not to be really connected to Boost.MultiIndex. My hunch is this is related to the precompiled header effect you talked about some posts ago, or that there's an evil macro affecting this very simple code.
To make sense of evil macro errors, I often end up resorting to looking at the preprocessed source. Right-click your .cpp file in Visual Studio, Properties, Configuration Properties, C/C++, Preprocessor, and change Preprocess to a File to Yes (/P). Then CTRL-F7 that file, and look for the .i on your disk. The file will be big, but look for your own code in there, at the end, and related to the error you get, and if a macro replaced your program text in an unexpected manner, you'll know the evil macro's name (the original name in your code, now replaced to some crap that doesn't compile), and can try to find it in the header you #include (directly or not). Not sure if this works with precompiled headers. --DD
[To make sense of evil macro errors, I often end up resorting to looking at
the preprocessed source.]
Sure thanks Dominique! But I am 100% sure there is no redefinition of new
in our code here. We use another version "customNew" to use a safer "new".
Joaquin,
I forgot to mention that changing "Use preprocessed headers" to No/Yes did
not make a difference. I confirmed this by running the stand alone test
program in both modes and it was successful in both. So I was thinking of
ruling that possibility out.
About the steps you asked me to follow to experiment to narrow down the
problem, I will do that today and reply to you.
Thanks,
Ram
On Wed, Sep 21, 2016 at 8:36 PM, Dominique Devienne
On Wed, Sep 21, 2016 at 4:56 PM, Joaquin M López Muñoz < joaquinlopezmunoz@gmail.com> wrote:
El 21/09/2016 a las 13:58, Ram escribió:
Yes, it shows that the problem seems not to be really connected to Boost.MultiIndex. My hunch is this is related to the precompiled header effect you talked about some posts ago, or that there's an evil macro affecting this very simple code.
To make sense of evil macro errors, I often end up resorting to looking at the preprocessed source. Right-click your .cpp file in Visual Studio, Properties, Configuration Properties, C/C++, Preprocessor, and change Preprocess to a File to Yes (/P). Then CTRL-F7 that file, and look for the .i on your disk. The file will be big, but look for your own code in there, at the end, and related to the error you get, and if a macro replaced your program text in an unexpected manner, you'll know the evil macro's name (the original name in your code, now replaced to some crap that doesn't compile), and can try to find it in the header you #include (directly or not). Not sure if this works with precompiled headers. --DD
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi Joaquin,
Sorry for the delayed response.
I tried what you said and
[
1. Continuing with your example.cpp file, where you last inserted the
boost::detail::allocator::construct bit, please remove all usage of
Boost.MultiIndex
and its headers, and simply add this #include
#include
On 29/09/2016 01:23, Ram wrote:
2. If the answer to the above is affirmative, please start removing headers (and the code that depends on them), *one header at a time*. Continue after you've removed everything (a) or suddenly the error disappears (b).
The error disappears only when I remove the multi_index declaration. After which the thing is of no use to me.
Previously you have said that using it standalone in a separate project works correctly. This means that the problem is either with the project settings or with other things you have #included. If you have really tried removing *every other* #include (including stdafx.h and any other project-specific includes) so that it still fails when you include nothing but the Boost and CRT headers, then that suggests the problem is your project settings. (More likely, though, you forgot that stdafx.h was one of the headers you should have tried removing. So try that. You will have to disable precompiled headers when you do that.)
Hi Gavin,
[
Previously you have said that using it standalone in a separate project
works correctly. This means that the problem is either with the project
settings or with other things you have #included.
If you have really tried removing *every other* #include (including
stdafx.h and any other project-specific includes) so that it still fails
when you include nothing but the Boost and CRT headers, then that suggests
the problem is your project settings.
(More likely, though, you forgot that stdafx.h was one of the headers you
should have tried removing. So try that. You will have to disable
precompiled headers when you do that.)
]
Will try this after I try the other suggestion in the other thread of
seeing the pre-processor output and trying to figure out if something is
messed up there. I want to try this later since I am working on a huge
project and this file is huge by itself and has over 15 or more includes.
Thanks,
Ram
On Thu, Sep 29, 2016 at 5:52 AM, Gavin Lambert
On 29/09/2016 01:23, Ram wrote:
2. If the answer to the above is affirmative, please start removing
headers (and the code that depends on them), *one header at a time*. Continue after you've removed everything (a) or suddenly the error disappears (b).
The error disappears only when I remove the multi_index declaration. After which the thing is of no use to me.
Previously you have said that using it standalone in a separate project works correctly. This means that the problem is either with the project settings or with other things you have #included.
If you have really tried removing *every other* #include (including stdafx.h and any other project-specific includes) so that it still fails when you include nothing but the Boost and CRT headers, then that suggests the problem is your project settings.
(More likely, though, you forgot that stdafx.h was one of the headers you should have tried removing. So try that. You will have to disable precompiled headers when you do that.)
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On 29/09/2016 16:54, Ram wrote:
Will try this after I try the other suggestion in the other thread of seeing the pre-processor output and trying to figure out if something is messed up there. I want to try this later since I am working on a huge project and this file is huge by itself and has over 15 or more includes.
You can do it the other way around as well. Create a new cpp file in your project that has nothing but the STL and Boost includes (no stdafx.h) and some basic exercising code and see if it compiles (it should, unless the problem is a project setting). Then gradually add your app-specific headers one at a time until it breaks. If it's a "big" header that breaks it (like stdafx.h itself), then try adding the individual includes within that header instead of including the header itself, again one at a time until it breaks. If there's lots of includes, you can do a bisection search on it -- add half at a time, then if it breaks remove half of those, etc. If you're careful this can be a bit faster sometimes but it's probably simpler to stick to one at a time if your compile times are fairly short (which they should be if you're just compiling the one file each time).
[
You can do it the other way around as well. Create a new cpp file in your
project that has nothing but the STL and Boost includes (no stdafx.h) and
some basic exercising code and see if it compiles (it should, unless the
problem is a project setting).
]
Sure, I will try this and let you know.
Meanwhile, in the other thread I have given the relevant part of the
preprocessed code. Please do let me know if you find anything there.
Thanks,
Ram
On Thu, Sep 29, 2016 at 10:57 AM, Gavin Lambert
On 29/09/2016 16:54, Ram wrote:
Will try this after I try the other suggestion in the other thread of seeing the pre-processor output and trying to figure out if something is messed up there. I want to try this later since I am working on a huge project and this file is huge by itself and has over 15 or more includes.
You can do it the other way around as well. Create a new cpp file in your project that has nothing but the STL and Boost includes (no stdafx.h) and some basic exercising code and see if it compiles (it should, unless the problem is a project setting).
Then gradually add your app-specific headers one at a time until it breaks. If it's a "big" header that breaks it (like stdafx.h itself), then try adding the individual includes within that header instead of including the header itself, again one at a time until it breaks.
If there's lots of includes, you can do a bisection search on it -- add half at a time, then if it breaks remove half of those, etc. If you're careful this can be a bit faster sometimes but it's probably simpler to stick to one at a time if your compile times are fairly short (which they should be if you're just compiling the one file each time).
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (4)
-
Dominique Devienne
-
Gavin Lambert
-
Joaquin M López Muñoz
-
Ram