Thread View: gnu.g++.bug
2 messages
2 total messages
Started by rfg
Sun, 17 Dec 1989 19:36
bug 12178901 (1.36.1) - linkage of global const objects
Author: rfg
Date: Sun, 17 Dec 1989 19:36
Date: Sun, 17 Dec 1989 19:36
13 lines
780 bytes
780 bytes
// bug 12178901 - linkage of global const objects // What is the `linkage' of const objects in C++? // GCC generates code for the following such that `ci' has // extern linkage, and such that its initial value is 99. // G++ 1.36.1 however optimizes this declaration into nothing. // Thus, if some other file contained `extern const int ci;' // that other file would fail to link. const int ci = 99;
bug 12178901 (1.36.1) - linkage of global const objects
Author: Michael Tiemann
Date: Mon, 18 Dec 1989 20:32
Date: Mon, 18 Dec 1989 20:32
29 lines
1502 bytes
1502 bytes
Date: Sun, 17 Dec 89 11:36:06 PST From: rfg@ics.uci.edu // bug 12178901 - linkage of global const objects // What is the `linkage' of const objects in C++? // GCC generates code for the following such that `ci' has // extern linkage, and such that its initial value is 99. // G++ 1.36.1 however optimizes this declaration into nothing. // Thus, if some other file contained `extern const int ci;' // that other file would fail to link. const int ci = 99; If you want GNU C++ to export these declarations, it is sufficient only to declare `extern const int ci;' prior to declaring its initial value. This gives expected behavior in expected case, namely that the file which provides the definition of ci will also include a files which contains its extern declaration. Unless you have been asleep for the past year, you know that declaring things extern in C files (rather than in .h files) is more and more becomming a no-no. 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