davidmalcolm / gcc-python-plugin

GCC plugin that embeds CPython inside the compiler
GNU General Public License v3.0
199 stars 58 forks source link

define_macro should accept a second argument #46

Closed davidmalcolm closed 7 years ago

davidmalcolm commented 7 years ago

gcc.define_macro should accept a second argument holding the expansion for the macro.

davidmalcolm commented 7 years ago

Imported from trac issue 6. Created by tromey on 2011-10-31T09:25:11, last modified: 2012-02-01T20:30:11

davidmalcolm commented 7 years ago

Trac comment by dmalcolm on 2012-01-11 14:44:01:

The documentation says:

gcc.define_macro(name)

Defines a preprocessor macro with the given name, which may be of use for code that needs to test for the presence of your script."

However, it's actually already possible to create a macro with a specific expansion; see tests/plugin/macros/correct/ which uses: {{{ gcc.define_macro('BAR=42') }}}

to define "BAR" to be 42.

I'm not sure whether or not that's a good thing; having a second argument seems more reasonable (not sure yet if it's implementable).

davidmalcolm commented 7 years ago

Trac comment by tromey on 2012-01-24 14:51:18:

You could always implement it by string concatenation in define_macro :)

However, this is good enough for me, so I suggest just making this a documentation bug.

davidmalcolm commented 7 years ago

Trac comment by dmalcolm on 2012-02-01 20:30:11:

Fixed in ecf2ac844d87945f782765c8ef7ce2a8877b15d6 as per your patch; thanks!