enums in C++
Nathan Sidwell
nathan@codesourcery.com
Tue Apr 18 08:02:00 GMT 2000
Ulrich Drepper wrote:
>
> Nathan Sidwell <nathan@codesourcery.com> writes:
>
> > > return a + foo (A | B);
> > this is not legal C++. there is no implicit conversion from int
> > to enum. You need an explict cast. Hence the error.
>
> But I was calling a C function.
You were calling
extern "C" int foo (enum ex_enum);
that calls for an argument of type `enum ex_enum'. The "C" linkage
only affects linkage, not promotions of the parameters. If you want
it to be compatible with
extern int foo (arg)
enum ex_enum arg;
you must give the prototype the default promoted parameters
extern "C" int foo (int);
(as I'm sure you know).
Remember, stuff inside `extern "C" { ... }' must still be valid
C++. Also remember, the set of overloaded functions named `foo' must
have distinct parameters, only one of the set can have C linkage.
Hope this helps.
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
More information about the Gcc-bugs
mailing list