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

Remove LUALIB_API from method definitions #229

Closed
KaleidoDeer opened this issue Nov 22, 2021 · 2 comments · Fixed by #235
Closed

Remove LUALIB_API from method definitions #229

KaleidoDeer opened this issue Nov 22, 2021 · 2 comments · Fixed by #235
Labels
enhancement New feature or request pr welcome Please contribute a pull request

Comments

@KaleidoDeer
Copy link
Contributor

KaleidoDeer commented Nov 22, 2021

Now it is to my understanding the LUA_API and LUALIB_API are macros to help aid in the exporting of methods you would likely use. This is extremely handy for say disabling name managing via extern C and exporting in dynamic libraries via declspec to improve interop with other languages without modifying the source code tediously too much.

In most cases this does fine however declspec specifically can only go on method declarations and can't go on definitions with bodies which will cause a C2491 compile error. The main culprit of this seems to be the built-in libraries using LUALIB_API ,luaopen_math being a prime example here.

These macros should only exist on method declarations to make interop more seamless.

@KaleidoDeer KaleidoDeer added the enhancement New feature or request label Nov 22, 2021
@zeux
Copy link
Collaborator

zeux commented Nov 22, 2021

These macros are only supposed to be used in header files; the fact that they are used in the source files is an oversight (LUA_API isn't for example). So it should be sufficient to remove the _API macros from sources.

@zeux zeux added the pr welcome Please contribute a pull request label Nov 22, 2021
@KaleidoDeer KaleidoDeer changed the title Separate built-in library definition and declaration for public APIs Remove LUALIB_API from method definitions Nov 22, 2021
@KaleidoDeer
Copy link
Contributor Author

These macros are only supposed to be used in header files; the fact that they are used in the source files is an oversight (LUA_API isn't for example). So it should be sufficient to remove the _API macros from sources.

Ah yeah I didn't look closely enough in the header to see the declarations are already separate there. I'll modify the issue to be more clear, I'll have a PR to fix this tonight since it's safe to remove.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pr welcome Please contribute a pull request
Development

Successfully merging a pull request may close this issue.

2 participants