Thread View: gnu.g++.bug
2 messages
2 total messages
Started by James Clark
Thu, 11 May 1989 08:44
extern "C" int optind;
Author: James Clark
Date: Thu, 11 May 1989 08:44
Date: Thu, 11 May 1989 08:44
19 lines
882 bytes
882 bytes
I'm a bit confused about whether `extern "C"' is applicable to data as well as functions. I was using getopt(), so I declared `optind' as: extern "C" int optind; It turned out that this causes a definition of optind to be emitted, which seems to prevent getopt() from working. Declaring it as extern int optind: makes it work. So is `extern "C"' supposed to work with data? If so, how do you say that you want to refer to something, not define it? James Clark jjc@jclark.uucp
extern "C" int optind;
Author: Michael Tiemann
Date: Thu, 11 May 1989 12:38
Date: Thu, 11 May 1989 12:38
33 lines
1419 bytes
1419 bytes
Date: Thu, 11 May 89 09:44:00 BST From: James Clark <jclark!jjc@uunet.uu.net> I'm a bit confused about whether `extern "C"' is applicable to data as well as functions. I was using getopt(), so I declared `optind' as: extern "C" int optind; It turned out that this causes a definition of optind to be emitted, which seems to prevent getopt() from working. Declaring it as extern int optind: makes it work. So is `extern "C"' supposed to work with data? If so, how do you say that you want to refer to something, not define it? This will work: extern "C" extern int optind; James Clark jjc@jclark.uucp In the absence of more information, I think of extern "C" as being a wrapper for C code, and not to mean that everything inside is automatically to be declared extern. This is easily enough implemented, but I am not sure that is the right idea. Michael
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads