Date: Wed, 21 Jun 2000 15:33:48 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: pavenis AT lanet DOT lv cc: djgpp AT delorie DOT com Subject: Re: Inline asm: lcall & various binutils versions In-Reply-To: <3950C2BF.16877.34C3C3@localhost> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Wed, 21 Jun 2000 pavenis AT lanet DOT lv wrote: > > AFAIK, inline assembly doesn't go through cpp; GCC emits it in the > > form of preprocessed assembly. So you cannot have any preprocessor > > directives inside the asm() block. > > Wrong. > > There are no problems using #ifdef and similar stuff inside inline > assembler. Inline assembler is normally recognised by cc1 or cc1plus > so it's only after cpp have processed file. This is a misunderstanding: what I meant to say was that the inline assembly doesn't go through preprocessor *after* cc1 or cc1plus wrote it to the output, i.e. between cc1 and Gas. It goes without saying that the C/C++ source itself goes through preprocessor. But at that stage, the asm is not interpreted except for constraints and clobber lists. > #define TEST > #define FOO "inc %%eax" > > int main (void) > { > int foo = 1; > asm ( "inc %%eax\t\n" > "inc %%eax\t\n" > #ifdef TEST > "inc %%eax\t\n" > #endif > FOO "\t\n" > : "=a" (foo) > : "a" (foo) > ); > return foo; > } In this example, the preprocessor directives are on the C level, not on the assembly level. To be on assembly level, they would need to be inside the quoted assembly code, not outside it. I'm sorry if my wording was unclear.