[Gc] Determining if pointer GC allocated

Hans Aberg haberg-1 at telia.com
Sat Dec 31 02:00:42 PST 2011


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







More information about the Gc mailing list