Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
preprocessor in cython
# A trick to embed preprocessors in cython
cdef extern from *:
cdef void EMIT_IF_PYTHON_VERSION_HEX_LT_37 "#if PY_VERSION_HEX < 0x03070000 //" ()
cdef void EMIT_ELSE "#else //" ()
cdef void EMIT_ENDIF "#endif //" ()
EMIT_IF_PYTHON_VERSION_HEX_LT_37()
EMIT_ELSE()
EMIT_ENDIF()
@ozars

This comment has been minimized.

Copy link

@ozars ozars commented Jun 18, 2019

Great trick! Still working as of Cython 0.29.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.