Jayen
Jayen

Reputation: 6079

string in #define macro in cython in notebook

I have an iPython notebook and I can specify cython macros fine with something like

# distutils: define_macros=NAME=VALUE

but now I want to pass VALUE as a string "VALUE"

# distutils: define_macros=NAME="VALUE"

It IS passing a string, but it's passing "__Pyx_L1_".

I tried '"VALUE"' and \"VALUE\" but they give compile errors because ' is for a character and \ becomes a "stray".

Upvotes: 1

Views: 178

Answers (1)

ead
ead

Reputation: 34367

It looks like a bug to me, so probably for the time being one should use the following work around, using extra_compile_args-option of cython-magic:

%%cython -c=-DNAME="VALUE"
# here code

adding -DNAME="VALUE" to command line of the compiler and thus defining NAME.

Upvotes: 1

Related Questions