-
Notifications
You must be signed in to change notification settings - Fork 135
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
RFC: add DLLEXPORT to utf8proc_get_property #17
Conversation
f92163e
to
f73d04d
Compare
whoops, thought it wasn't working any more after that second commit, it was just submodules getting the better of me for a minute. |
It looks fine to me, but this isn't my area. |
@@ -69,9 +69,15 @@ typedef int int32_t; | |||
typedef unsigned char bool; | |||
enum {false, true}; | |||
# endif | |||
# ifdef LIBRARY_EXPORTS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have this under #ifdef _MSC_VER
(MS Visual C++), but it seems like this should be in a separate #ifdef _WIN32
clause (so that it is used for any compiler on Windows).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it should. I wanted to avoid changing the existing MinGW build too dramatically, where either we have a -Wl,--export-all-symbols
somewhere or MinGW is just defaulting to exporting everything if there are no explicit dllexport instructions provided. If we make this definition apply for MinGW as well, then any function other than these 4 (which look to be the only ones currently ccall
ed somewhere in base Julia) will no longer be exported from the DLL (libjulia in this case, since we statically link in libmojibake).
In some ways the __declspec(dllexport)
annotation is like saying "this is part of the public API if this library gets linked into a DLL." I don't know enough about utf8proc to draw that line beyond the 4 functions that are used in base Julia code (not sure about anything in src/
for example) - should everything be exported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every function in the header file should be exported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stevengj okeydokey, thanks. I'll work on that (and change the DLLEXPORT
define to be for any _WIN32
, and test with MinGW to make sure that doesn't break anything) in about half an hour, after the F1 race is over.
Every function in the header is now exported. I left off the constant int8 array Do we want to |
Actually, it looks like it should only be for |
In general, I would think that anything listed in the header file should be in the public API. (Conversely, if it isn't in the public API, it shouldn't be in the header file.) Including this global array (which tells you the length of a codepoint's encoding from the first byte, and hence is useful for inlined iteration over a UTF-8 string). |
I'll add Hrm, Julia uses the |
017aea0
to
a840e5d
Compare
Yes, the more basic the library, the more portable I feel it should be, within reason. |
Makes perfect sense to me. I don't get quite what |
@@ -6,7 +6,7 @@ MAKE=make | |||
|
|||
# settings | |||
|
|||
cflags = -O2 -std=c99 -pedantic -Wall -fpic $(CFLAGS) | |||
cflags = -O2 -std=c99 -pedantic -Wall -fpic -DLIBRARY_EXPORTS $(CFLAGS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would probably be better to use something like _MOJIBAKE_EXPORTS
here to avoid accidentally clashing with user-defined macros. (It is not too far-fetched to imagine mojibake.h
being #included
in a project that defines a LIBRARY_EXPORTS
macro.)
@stevengj sure. Did you mean with a leading underscore? |
Yes, I put the leading underscore there just to emphasize that this is not a macro for users to fiddle with. |
Depends what you mean by "users," but anyone who wants to depend on this library and have the API exported from a DLL will need to be aware of and define this macro (at mojibake build time), particularly if incorporating the library as a dependency in a build system that doesn't use the Makefile here. |
RFC: add DLLEXPORT to utf8proc_get_property
Looks good to merge, in any case. |
Great, thanks for looking it over. Can continue to be refined, of course. |
ref JuliaLang/julia#7761 (comment)
This is needed to finish building the system image when using MSVC to build Julia. More of the API will probably need to be DLLEXPORT'ed to pass any Julia tests that use other functions.