STL question

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
midgetfc
Posts: 60
Joined: Fri May 15, 2009 2:50 pm

STL question

Post by midgetfc »

Hello,
I have a problem compiling rev 2706 (06/12/09), in src/Mod/Mesh/Gui/CMakeFiles/MeshGui.dir/RemoveComponents.cpp:
I'm on a Debian Squeeze, and the compiler is gcc version 4.3.4 (Debian 4.3.4-6). Below is the compiler error message:

src/Mod/Mesh/Gui/RemoveComponents.cpp: In member function ‘void MeshGui::RemoveComponents::on_selectAll_clicked()’:
src/Mod/Mesh/Gui/RemoveComponents.cpp:153: error: no matching function for call to ‘generate(__gnu_cxx::__normal_iterator<long unsigned int*, std::vector<long unsigned int, std::allocator<long unsigned int> > >, __gnu_cxx::__normal_iterator<long unsigned int*, std::vector<long unsigned int, std::allocator<long unsigned int> > >, MeshGui::RemoveComponents::on_selectAll_clicked()::iotaGen&)’

It's as if the compiler could'nt instantiate the 'generate' function. More precisely, it doesn't recognise iota_gen as a 'Generator'.

If struct iotaGen definition and iota_gen declaration are pushed out of on_selectAll_clicked() function body, everything is fine.
I don't quite understand why, but I'm not very cute in C++.
Are some of you running across the same problem ?
Does anybody know why that seemingly correct syntax is not taken by g++ ?
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: STL question

Post by jriegel »

I have the same problem on openSuse. We will look into that!

Jürgen
Stop whining - start coding!
midgetfc
Posts: 60
Joined: Fri May 15, 2009 2:50 pm

Re: STL question

Post by midgetfc »

I'm conscious that it doesn't look too nice, but do you consider it a complete heresy if iotaGen definition appears outside the function, like below:

Code: Select all

typedef struct iotaGen {

    unsigned long operator()() { return n++; }

    iotaGen() : n(0) {}
private:

    unsigned long n;

} iotaGen_t;

void RemoveComponents::on_selectAll_clicked()

{
    // select the complete meshes

    iotaGen_t iota_gen;
   ...
}
at least as a rough fix to compile.
Cheers
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: STL question

Post by wmayer »

In the latest SVN revision this is fixed.
Post Reply