D.gnu - Instantiating a class in d file with an extern (c) block causes immediate segfault!
- kamatsu <whiteslug gmail.com> Jul 31 2008
- John Grindstaff <perfectcell14 yahoo.com> Jul 31 2008
- Gregor Richards <Richards codu.org> Jul 31 2008
- FreekSh0w86 <perfectcell14 yahoo.com> Jul 31 2008
Content-Type: text/plain On my system, when I do: gdc *.c *.d ./a.out I get: segmentation fault I can instantiate classes fine with normal D, but as soon as the extern(c) stuff creeps in bang - no classes for me! Can you please explain what's wrong? And how I can fix it?
Jul 31 2008
Is this version of gdc you are using compiled against GCC 4.2.* or 4.1.*? If you are trying to use nested functions, it is probably best to use 4.1 because I have had random crashes with nested functions in 4.2.* kamatsu wrote:On my system, when I do: gdc *.c *.d ./a.out I get: segmentation fault I can instantiate classes fine with normal D, but as soon as the extern(c) stuff creeps in bang - no classes for me! Can you please explain what's wrong? And how I can fix it?
Jul 31 2008
kamatsu wrote:On my system, when I do: gdc *.c *.d ./a.out I get: segmentation fault I can instantiate classes fine with normal D, but as soon as the extern(c) stuff creeps in bang - no classes for me! Can you please explain what's wrong? And how I can fix it?
You're using a C main and haven't initialized the D environment. Initializing D from C is quite difficult, I would recommend using a D main (such that D is initialized automatically) and using it to call the primary C function. - Gregor Richards
Jul 31 2008
Oh I had no idea this was an attempt to invoke D runtime from a C program. If you manage to do that on a non-Windows platform successfully, that would be a super-human feat. The only way I've managed to even come close to doing something like that is build all my source objects separately into *.o files and link them together with GDC _and_ invoke the D runtime by calling rt_init or whatever. But that is for Tango, Phobos is probably different. Gregor Richards wrote:kamatsu wrote:On my system, when I do: gdc *.c *.d ./a.out I get: segmentation fault I can instantiate classes fine with normal D, but as soon as the extern(c) stuff creeps in bang - no classes for me! Can you please explain what's wrong? And how I can fix it?
You're using a C main and haven't initialized the D environment. Initializing D from C is quite difficult, I would recommend using a D main (such that D is initialized automatically) and using it to call the primary C function. - Gregor Richards
Jul 31 2008









John Grindstaff <perfectcell14 yahoo.com> 