[Cython] Fwd: Question about how best require compiler options for C sources
Erik Bray
erik.m.bray at gmail.com
Mon Apr 11 09:23:06 EDT 2016
On Mon, Apr 11, 2016 at 2:51 PM, Nathaniel Smith <njs at vorpus.org> wrote:
> Now, back to your example: Here the caller and callee are both compiled into
> the same shared library, so you don't want dllexport/dllimport at all, you
> just want a shared-library-internal symbol, which as we see is much easier.
Sorry, I'll respond more to your (helpfully detailed and precise)
message in a second. But something I wanted to point out is that my
example is incomplete and I should have arranged a more complete
example. In this case I really do want the symbol "hello" to be
exported by the DLL, as well as be understood between translation
units making up the same library. A more complete example would have
shown a separate library which links with "foo" and uses the "hello"
function in it.
Yes, it's arguable that exporting anything more than then initmodule
function from a Python extension module is not best practice, but the
possibility should not be ruled out either.
So I think later on you hit correctly on the deeper problem, which is
that Cython currently doesn't have a great way to distinguish between
intra-library visibility and *inter*-library visibility.
And if both are needed then some DL_IMPORT-like macro is needed that
sets the visibility for a symbol correctly depending on the context in
which it's being used. (And yes, this is not a problem on *nix, but it
is on Windows due to the way __declspec(dllimport) causes name
mangling :(
Thanks,
Erik
More information about the cython-devel
mailing list