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"
- To: Dima Volodin <dvv at egcs dot dvv dot ru>
- Subject: Re: C++ bug when using extern "C"
- From: Dirk De Rycke <dirk dot de dot rycke at chello dot be>
- Date: Sun, 15 Jul 2001 20:12:04 +0200
- CC: gcc-bugs at gcc dot gnu dot org
- References: <3B4F619C.B6630276@chello.be> <3b59cef3.636831213@busybee>
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.
regards,
Dirk
> 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