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

Consider prefixing public functions with unique namespace #67

Open
jbaldwin opened this issue Apr 1, 2020 · 4 comments
Open

Consider prefixing public functions with unique namespace #67

jbaldwin opened this issue Apr 1, 2020 · 4 comments

Comments

@jbaldwin
Copy link

jbaldwin commented Apr 1, 2020

I ran into an interesting issue where linking a project with libmysql.a as well as this library caused some extremely weird behavior, and eventually I found out there was a namespace clash as mysql also declares two functions base64_encode() and base64_decode(). Please considering prefixing your library C functions with a unique namespace. I've gotten around this by forking and just naming them differently for now but I want to say thanks for the great library, I've enjoyed using it. I'd also make a PR but I don't know what you'd want to prefix with and it is a breaking change to the API.

@aklomp
Copy link
Owner

aklomp commented Apr 10, 2020

Hi, thanks for the suggestion. Currently, this library claims the base64 namespace for all global functions, macros, structures and other objects exposed in the public headers. I guess this can cause conflicts with other software that also claim that prefix, but in my opinion, base64 is a reasonable prefix for a base64 library to claim.

Changing the prefix would break API compatibility, and while I am not opposed to that as long as it's accompanied by a major version change, I'm hesitant to do it unless necessary. As a thought exercise, I tried to come up with a few alternative prefixes, but they all seem poor. libbase64 is overlong, b64 is probably too generic, and using a made-up name would be confusing. Is there a prefix you had in mind?

Possibly this can be solved/fixed in the future when the library switches to building with Cmake, it might make it easier to configure a custom namespace.

@jbaldwin
Copy link
Author

Yeah, I was unable to think of a good suggestion for a generic prefix as base64_ logically makes sense for this library.

How about an optional configuration define or macro which would prefix the functions accordingly if it is set by the user? Then you don't have to change the default API and users of the library can then pick any prefix they want. I know rapidjson uses this method to allow its users to namespace the entire codebase (its C++ but same concept I think).

@aklomp
Copy link
Owner

aklomp commented Apr 10, 2020

That sounds like a reasonable solution. However at this point it's hard to implement, because of the archaic way that the build system handles symbol visibility. All visible symbols are currently enumerated in exports.txt, which is a static textfile.

So the plan is to move the library to a Cmake-based build system. That would remove a lot of the build cruft and replace it with new cruft, and would presumably make it easier to add this sort of customization.

Would you be OK if I leave this issue open, but not resolve it for the time being?

@jbaldwin
Copy link
Author

Yes, that sounds good to me. Thanks.

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

2 participants