Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Namespace problems with function name distance

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Namespace problems with function name distance


Chronological Thread 
  • From: Bernd Gaertner <>
  • To:
  • Subject: Re: [cgal-discuss] Namespace problems with function name distance
  • Date: Thu, 20 Sep 2007 17:03:05 +0200

Dear Martin,

the "experts" just had a round of discussions, and so far, the majority of them believes that it's a compiler bug. Recommended workaround: don't call it "distance".

Best,
Bernd.

Martin Baeker wrote:
Dear experts,

I just tried to upgrade from CGAL 3.1 to 3.3. (SuSe Linux 10.1 with
g++ (GCC) 4.1.0 (SUSE Linux)) However, I encounter some strange
behaviour when trying to define a function that is named "distance"

#include <iostream>
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/MP_Float.h>
typedef CGAL::Quotient<CGAL::MP_Float> NT;
typedef CGAL::Cartesian<NT> TutorialR;
typedef CGAL::Point_2<TutorialR> Point;
double distance(const Point & p, const Point & q)
{
return sqrt(CGAL::to_double(squared_distance(p,q )));
}
int main()
{
Point p1(1.,2.);
Point p2(2.,2.);
std::cout << (distance(p1,p2)) << std::endl;
return 0;
}

On compiling this, I get

/usr/bin/g++ -Wall -frounding-math '-I/home/gecko/martin/fem/abaqus/CGAL-3.3.1/include/CGAL/config/i686_Linux-2.6_g++-4.1.0' '-I/home/gecko/martin/fem/abaqus/CGAL-3.3.1/include' -I/usr/X11/include -I/usr/lib/qt3/include -g -c -o minitest.o minitest.C /usr/include/c++/4.1.0/bits/stl_iterator_base_types.h: In instantiation of »std::iterator_traits<CGAL::Point_2<CGAL::Cartesian<CGAL::Quotient<CGAL::MP_Float> > > >«:
minitest.C:18: instantiated from here
/usr/include/c++/4.1.0/bits/stl_iterator_base_types.h:129: Fehler: kein Typ namens
»iterator_category« in »class
CGAL::Point_2<CGAL::Cartesian<CGAL::Quotient<CGAL::MP_Float> > >«

As it seems, the function I defined is confused with the std::distance
function, but I do not understand how this happens. If I do the same
thing replacing the Point class with simple doubles, all is well.

Any help, hints, etc are very welcome,

Martin.



Priv.-Doz. Dr. Martin Bäker
Institut für Werkstoffe
Technische Universität Braunschweig
Langer Kamp 8
38106 Braunschweig
Germany
Tel.: 00-49-531-391-3073
Fax 00-49-531-391-3058
e-mail <>-- You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss



Archive powered by MHonArc 2.6.16.

Top of Page