This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: C++ bug when using extern "C"
On Sun, 15 Jul 2001 20:12:04 +0200, you wrote:
>Dima Volodin wrote:
>
>Dima,
>
>I do not agree. If you look at the object file
>[dirk@hades dirk]$ nm -s cppbug.o
>00000000 ? __FRAME_BEGIN__
>00000000 t gcc2_compiled.
>00000000 T xxx__FPFv_v
>0000000c T yyy
>
>One function (the workaround) was compiled with C mangling. So
>specifying the extern "C" linkage did work for that function
>but happened to fail for the other.
>Also I found in the watcom faq
>(http://www.azillionmonkeys.com/qed/watfaq.shtml at the end of Question
>19) that only the prototype needs to have the linkage specification.
>Have a look at http://www.mozilla.org/hacking/portable-cpp.html section
>19, there you see how header files containing the prototype
>should be adjusted not the C files containing the definition.
Well, these links are pretty much irrelevant :-) The authoritative
wording about it all can be found in [dcl.link/5] and [dcl.link/6], and
yes, you are right - your code defines xxx and yyy with "C" linkage, and
yes - it's a defect in 2.95.3. Sorry I didn't check my knowledge right
away. Anyway, 3.0 does it right:
[...]
.globl xxx
.type xxx,@function
xxx:
[...]
.globl yyy
.type yyy,@function
yyy:
[...]
.ident "GCC: (GNU) 3.0"
>Dirk
Cheers!
Dima
>> On Fri, 13 Jul 2001 23:01:16 +0200, you wrote:
>>
>> >Hi,
>> >
>> >Today I may have hit a bug in g++.
>> >Try compiling the following program with g++ -c
>> >
>> >extern "C" {
>> > void xxx(void (*f)());
>> > void yyy(void (*f)(void));
>> >}
>> >
>> >void xxx(void (*f)())
>> >{
>> >}
>> >
>> >void yyy(void (*f)(void))
>> >{
>> >}
>>
>> AFAIK, you must specify the linkage for both declarations and
>> definitions.
>>
>> >Dirk De Rycke
>>
>> Dima
>
>