enums in C++

Ulrich Drepper drepper@redhat.com
Tue Apr 18 09:48:00 GMT 2000


Nathan Sidwell <nathan@codesourcery.com> writes:

> Unless I'm missing something, only the name mangling is different, and
> that's something that happens well after overload resolution. (It's
> possible for a different calling convention too, but that also is after
> overload resolution.)

There are other things.  E.g.,

extern "C" {
struct foo
{
	int foo;
};
}

must be possible.

> If I understand you correctly, you want an extension to C++.

No, I want special treatement for C functions.

> to work as if it were C? rather than
> `someCfunc (ex_enum (enumA | enumB))'?

Yes.

> This leads to an ambiguity in the following,
> 	extern "C" int foo (enum ex_enum);	//1
> 	extern int foo (int);			//2
> 	foo (enumA | enumB);
> which should be called? C++ requires that 2 be called. What about
> 	extern "C" int foo (enum ex_enum);	// 1
> 	template<class T> int foo (T);		// 2
> 	foo (enumA | enumB);
> Here C++ requires template instantiation of foo<int>.

Simply warn about this and pick one.

-- 
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------


More information about the Gcc-bugs mailing list