This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: C++ bug when using extern "C"


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]