Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would like to be able to disable DLLEXPORT #96

Closed
madscientist opened this issue Feb 17, 2017 · 5 comments
Closed

Would like to be able to disable DLLEXPORT #96

madscientist opened this issue Feb 17, 2017 · 5 comments

Comments

@madscientist
Copy link
Contributor

In my system I'm linking utf8proc as a static library, into my shared library and I don't want the utf8proc symbols to be visible outside my shared library (in case the user of my shared library has their own version of this library or even other code which has symbol conflicts, in other libraries, etc.)

However currently there's no way to turn off the DLLEXPORT stuff in utf8proc.h. I'd appreciate it if there were a controlling macro I could add to my CFLAGS that would disable it, maybe something like:

#ifdef UTF8PROC_NO_DLLEXPORT
# define UTF8PROC_DLLEXPORT
#elif defined(_WIN32)
#  ifdef UTF8PROC_EXPORTS
#    define UTF8PROC_DLLEXPORT __declspec(dllexport)
#  else
#    define UTF8PROC_DLLEXPORT __declspec(dllimport)
#  endif
#elif __GNUC__ >= 4
#  define UTF8PROC_DLLEXPORT __attribute__ ((visibility("default")))
#else
#  define UTF8PROC_DLLEXPORT
#endif

or something along those lines; I can add -DUTF8PROC_NO_DLLEXPORT to CFLAGS to avoid any exporting.

@madscientist
Copy link
Contributor Author

Another alternative is to allow UTF8PROC_DLLEXPORT itself to be defined before this and test for that, then I can just set it to the empty string:

#ifndef UTF8PROC_DLLEXPORT
#  ifdef _WIN32
#    ifdef UTF8PROC_EXPORTS
#      define UTF8PROC_DLLEXPORT __declspec(dllexport)
#    else
#      define UTF8PROC_DLLEXPORT __declspec(dllimport)
#    endif
#  elif __GNUC__ >= 4
#    define UTF8PROC_DLLEXPORT __attribute__ ((visibility("default")))
#  else
#    define UTF8PROC_DLLEXPORT
#  endif
#endif

@vtjnash
Copy link
Contributor

vtjnash commented Feb 18, 2017

see PR #85

@madscientist
Copy link
Contributor Author

Thanks for that reference @vtjnash

FWIW, the reason for wanting to disable the visibility setting is this: I want to create my own shared library. In that shared library I want to link utf8proc statically, for use by my library. And I don't want the symbols from my utf8proc to be published to users of my shared library: they might by trying to link with their own version of libutf8proc.so which differs from mine in some way, or maybe they even have some other .so which happens to use the same symbol name, etc. Whatever the reason, my library is not intended to provide a utf8 interface I'm only using that internally.

When I compile my code I use the -fvisibility=hidden flag to ensure that all symbols are marked with hidden visibility except those that I want to export. If the utf8proc symbols are marked explicitly as having "default" visibility, they are also always exported which I don't want.

So, that's why I need to disable the "default" visibility setting in utf8proc (and also the __declspec() stuff in Windows, which I also build for).

Cheers!

@Thomas-Haase
Copy link

First of all, thanks for the suggested workarounds above.

Me too: the optional ability to build a static library instead of a dynamic library would be very welcome.

@stevengj
Copy link
Member

Closed by #123.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants