Out-of-line API-level doesn't compile with __declspec(dllimport) constants
Created originally on Bitbucket by Anonymous
Hi,
This is a windows issue. I have a DLL that exports some functions but it also exports some data. When I create my extension in-line it works, but when I do it out-of-line it fails with error C2099: initializer is not a constant.
Here some sample code:
works.py:
#!python
from cffi import FFI
_FFI = FFI()
_FFI.cdef("""
extern int my_value;
""")
_FFI.verify(
"extern __declspec(dllimport) int my_value;",
)
Note: The code above will fail with a linker error because my_value doesn't actually exist. That's not the bug. The bug is that the code below fails with a compiler error.
broken.py:
#!python
from cffi import FFI
_FFI = FFI()
_FFI.set_source(
"example",
"extern __declspec(dllimport) int my_value;",
)
_FFI.cdef("""
extern int my_value;
""")
if __name__ == "__main__":
_FFI.compile()