syntax error for egcs

Julian Payne jpayne@ilog.fr
Thu Aug 12 04:26:00 GMT 1999


Martin,

My problem comes from the following:

I have a method Ils2Viewed(O*) that is global, when I declare Ils2Viewed in
the template the compiler uses the name qualification of the template and so
tells me that the method that has been declared and the extern declaration
are ambigious. This also happens on some other compilers but these other
compilers except the :: qualification with the extern declaration. I have to
put the extern in the template code because the type of the parameter is one
of the template parameters. Here is an example that illustrates the problem
that I have, am I still doing something wrong?

class B
{
public:
  B(){}
};

void Ils2Viewed(B*){}

template <class O>
class A
{
public:
  A(){}
  void test(O*);
};

template <class O>
void
A<O>::test(O* o)
{
  extern void Ils2Viewed(O*);
  Ils2Viewed(o);
}

int
main()
{
  B b;
  A<B> a;
  a.test(&b);
  return 0;
}

g++     main.cpp   -o main
main.cpp: In method `void A<B>::test<B>(class B *)':
main.cpp:30:   instantiated from here
main.cpp:22: call of overloaded `Ils2Viewed (B *&)' is ambiguous
main.cpp:21: candidates are: Ils2Viewed(B *)
main.cpp:7:                 Ils2Viewed(B *)
make: *** [main] Error 1

Thanks,

Julian

----- Original Message -----
From: Martin v. Loewis <martin@mira.isdn.cs.tu-berlin.de>
To: <jpayne@ilog.fr>
Cc: <egcs-bugs@egcs.cygnus.com>; <server-team@ilog.fr>
Sent: Thursday, August 12, 1999 8:49 AM
Subject: Re: syntax error for egcs


> > {
> >   extern void ::Ils2Viewed(O*);
> >   ::Ils2Viewed(o);
> > }
>
> Thanks for your bug report. This is an error in your code; you must
> not qualify in an extern declaration. See 8.3, [decl.meaning]/1 for
> details.
>
> Regards,
> Martin
>



More information about the Gcc-bugs mailing list