inline asm outside functions

Marc Tardif marc@sitepak.com
Fri Dec 27 23:12:00 GMT 2002


OS: Linux 2.4.13 i686
gcc: 2.96

It does not seem possible to define inline asm statements which specify 
constraints outside of a function. For example, the following code will 
generate an error:

__asm__ ( \
   "     .align 4\n" \
   ".globl foo\n" \
   "     .type   foo,@function\n" \
   "foo:\n" \
   "     movl    %0, %%eax\n" \
   "     jmp     *(%%eax)\n" \
   : /* no output */ \
   : "n" (offset));

The error generated is:

parse error before `:'

The hacked solution to this problem is to create a dummy function 
surrounding the inline asm statement.

Marc - Sitepak



More information about the Gcc-bugs mailing list