D
Daniele Benegiamo
Is the following program standard-compliant? I've compiled it with some
compilers and no errors or warnings are produced, but this is not a
demonstration.
The "incriminated" part is the declaration:
extern "C" struct X;
that is then defined as:
class X {};
I know that 'extern "C"' change only the linkage specification, but
forwarding declarations in C++ /usually/ don't allow usage of different
class-keys.
Regards,
Daniele.
/* declarations */
extern "C" {
struct X;
X * new_X ();
void delete_X (X *);
}
/* definitions */
class X {};
extern "C" {
X * new_X ()
{
return new X ();
}
void delete_X (X * p)
{
delete p;
}
} // extern "C"
int main ()
{
X * p = new_X ();
delete_X (p);
return 0;
}
<<<<<<<<<<<<<<<<
compilers and no errors or warnings are produced, but this is not a
demonstration.
The "incriminated" part is the declaration:
extern "C" struct X;
that is then defined as:
class X {};
I know that 'extern "C"' change only the linkage specification, but
forwarding declarations in C++ /usually/ don't allow usage of different
class-keys.
Regards,
Daniele.
/* declarations */
extern "C" {
struct X;
X * new_X ();
void delete_X (X *);
}
/* definitions */
class X {};
extern "C" {
X * new_X ()
{
return new X ();
}
void delete_X (X * p)
{
delete p;
}
} // extern "C"
int main ()
{
X * p = new_X ();
delete_X (p);
return 0;
}
<<<<<<<<<<<<<<<<