René Dudfield schrieb am 17.06.19 um 08:59:
> Is there a nice way to use macros for feature selection with cython?
>
> For example, I would like to use this macro at C compile time (not cython
> compile time).
>
> #if defined(SDL_VERSION_ATLEAST)
> #if (SDL_VERSION_ATLEAST(2, 0, 5))
> SDL_SetWindowResizable(win, flags & PGS_RESIZABLE);
> #endif
> #endif
>
> It seems the best way available is to make a .h/.c file(s) that do all the
> pre-processor magic, then use that from cython.
Yes, that's pretty much how you'd do it, also because you would normally
want these decisions to be taken by the C compiler and not by Cython. You
could define a C macro or inline function that adapts to the defines, and
then call that from your Cython code.
You can write this glue code inside of your Cython file, though:
http://docs.cython.org/en/latest/src/userguide/external_C_code.html#including-verbatim-c-code
Stefan