Article View: gnu.g++.bug
Article #140external C linkage bug in g++ for gcc-2.2.2
From: Jeff Greif
Date: Wed, 22 Jul 1992 18:02
Date: Wed, 22 Jul 1992 18:02
43 lines
1594 bytes
1594 bytes
I've tried this out on Sparc SunOS 4.1.1 and DG-Aviion-dgux5.4.1.
The attached file foo.cc gets an error "uninitialized constant xxxxx"
when compiled with gcc -g. None of the other extern "C" lines give
an error.
According to the ARM, p. 118, first annotation,
extern "C" int a2;
is supposed to be a declaration, not a definition, while
extern "C" { int a1; }
is a definition, and can only be made a declaration using
extern "C" {extern int a1;}
G++ seems to be confused about this distinction when an aggregate
is involved.
The actual case that caused the original problem was in dgux5.4.1,
/usr/include/limits.h, which includes various stuff boiling down to
#if defined(__cplusplus)
#define _EXTERN extern "C"
#else
#define _EXTERN extern
#endif
typedef union { unsigned long i[2]; double d; } h_val;
_EXTERN const h_val xxxxx;
---------------------------------------------------------------------
/* Begin foo.cc */
#include <stdio.h>
typedef union { unsigned long i[2]; double d; } zork;
extern "C" const zork xxxxx;
extern "C" const int aaaaa;
extern "C" int bbbbb;
extern const zork yyyyy;
main()
{
printf("Hello world.\n");
exit(0);
}
Technical Details
Message-ID:
<9207221802.AA19707@quaestor>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!inference.COM!jmgShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!inference.COM!jmg From: jmg@inference.COM (Jeff Greif) Subject: external C linkage bug in g++ for gcc-2.2.2 Message-ID: <9207221802.AA19707@quaestor> Sender: gnulists@ai.mit.edu Organization: Inference Corporation Distribution: gnu Date: Wed, 22 Jul 1992 18:02:16 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 44