From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Williams To: Chris Howard Cc: c++-embedded@cygnus.com, crossgcc@cygnus.com Subject: Re: gcc vs g++ and linking with as Date: Thu, 25 Jun 1998 23:03:00 -0000 Message-id: <199806260603.XAA24037@icarus.icarus.com> References: <35926CEF.9F0E576F@intellistor.com> X-SW-Source: 1998/msg00008.html choward@intellistor.com said: > Compiling with as,gcc and linking with ld works fine. Compiling with > as,g++ and linking with ld does not work, > undefined symbols for those things written in assembler. Even in C you can have troubles. What I do is use the "asm" attribute to declare external variables, i.e.: extern unsigned char __index_space asm("__index_space__"); which causes __index_space__ to be the actual symbol name at link time. A function would work like this: int foo(int i) asm("test_symbol"); int foo(int i) { return i+1; } This works with (GNU) C and C++. It is a good thing to do even with C because sometimes you get the leasing _, sometimes you don't. etc. -- Steve Williams "The woods are lovely, dark and deep. steve@icarus.com But I have promises to keep, steve@picturel.com and lines to code before I sleep, http://www.picturel.com And lines to code before I sleep."