Re[2]: [Gc] Determining if pointer GC allocated

Ivan Maidanski ivmai at mail.ru
Sat Dec 31 04:24:34 PST 2011


Hi,

I meant some C legacy code is not legal in C++.
Eg.:

ok:
gcc -I include -c extra/gc.c

cannot compile:
gcc -I include -c -x c++ extra/gc.c

Regards.

31 12 2011, 14:05 Hans Aberg <haberg-1 at telia.com>:
> On 31 Dec 2011, at 09:55, Ivan Maidanski wrote:
> 
> >>> If your test case were written in C then it would be possible to define GC_API=static and include extra/gc.c directly from your code thus resulting everything to be compiled as a single module with GC_is_heap_ptr inlined (at some level of -O).
> >>
> >> It might be possible from C++ using:
> >> extern "C" {
> >> #define GC_API static
> >> #include "extra/gc.c"
> >> }
> >> but I get the error:
> >> In file included from ./extra/gc.c:38:
> >> ./extra/../backgraph.c:15:10: fatal error: 'private/dbg_mlc.h' file not found
> >> #include "private/dbg_mlc.h"
> >>         ^
> >> 1 error generated.
> >
> > This error is caused by missing -I include option (as private/dbg_mlc.h in in include folder), also you might need to include -I libatomic_ops/src (if you set -D GC_THREADS).
> 
> Adding it generates more errors:
> 
> In file included from bdwgc/extra/gc.c:39:
> bdwgc/extra/../blacklst.c:52:15: error: redefinition of 'GC_black_list_spacing'
> GC_INNER word GC_black_list_spacing = MINHINCR * HBLKSIZE;
>               ^
> bdwgc/include/private/gc_priv.h:1311:16: note: previous definition is here
> GC_EXTERN word GC_black_list_spacing;
> 
> > The real problem with including C code from C++ is that "extern C" only influences name mangling (AFAIK) but not the semantics.
> 
> I'm not sure what have in mind here. The compilers I use have the same ABI. (On OS X 10.7.2, I have clang 3.0, llvm-gcc-4.2, gcc 4.6.2.)
> 
> Hans
> 
> _______________________________________________
> Gc mailing list
> Gc at linux.hpl.hp.com
> http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
> 



More information about the Gc mailing list