[Cython] Gsoc project

Nathaniel Smith njs at pobox.com
Thu Mar 29 19:32:19 CEST 2012

On Thu, Mar 29, 2012 at 5:25 PM, David Malcolm <dmalcolm at redhat.com> wrote:
> On Thu, 2012-03-29 at 11:10 +0100, mark florisson wrote:
>> > Then what happens if you have
>> >
>> > #ifdef FOO
>> > #define BAR 3
>> > #else
>> > #define BAR 4
>> > #endif
>> >
>> > ?? I'm not saying it is hard, but perhaps no longer completely trivial :-)
> Yeah.  I have no idea to what extent the C preprocessor stuff is exposed
> internally, and if the branching logic is preserved in any way that's
> usable.

I'm pretty sure macros and such are gone before the C parser ever gets
to see the token stream.

But, it should be easy to pull out #define's on a second pass, using
something like
  gcc $CFLAGS -E -dM myfile.h
and then just scanning the output with a trivial "parser". (I'm not
sure which of -dM, -dD, -dU you want.)

-- Nathaniel

More information about the cython-devel mailing list