On Sat, 6 Dec 2008 13:47:26 -0800 (PST), ats <[EMAIL PROTECTED]> wrote: > Hello, > > This is my first posting to a Python group (and I'm starting with > Python seriously only now) , so bear with me if I make some mistakes. > > I want to generate 3 different versions of a C++ source code, > basically injecting different flavours of inline assembler depending > on target compiler/CPU. > > Code generation should be integrated into a 'master source file' which > is the processed and generates the right code for GCC / MSVC or other > cases. Something like: > > int FastAdd( int t1, int t2 ){ > int r; > ##if USE_INLINE_ASM > #ARG( eax, "t1") > #ARG( ebx, "t2") > #ASM( "add", ebx, eax ) > #RES( eax, "r" ) > ##else > r = t1+t2; > ##endif > return r; > }
You didn't say explicitly, so I have to ask: is there a reason you cannot use the C++ preprocessor? It does exactly what you describe, and would be the least surprising solution to the readers. /Jorgen -- // Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.se> R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list