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

Define and use macros for exporting public functions for dll/dylib/so usages, enforce cdcel for public functions/callbacks #300

Merged
merged 6 commits into from
Dec 20, 2023

Conversation

CasualPokePlayer
Copy link
Contributor

No description provided.

@CasualPokePlayer CasualPokePlayer marked this pull request as ready for review December 14, 2023 04:17
… usages, enforce cdcel for public functions/callbacks
include/rc_export.h Show resolved Hide resolved
include/rc_export.h Show resolved Hide resolved
include/rc_export.h Outdated Show resolved Hide resolved
include/rc_export.h Outdated Show resolved Hide resolved
Default to RC_STATIC
Replace BUILDING_RC with RC_IMPORT (which is for external code using rcheevos as a shared library)
Check if GNUC version is high enough (>= 4) for the visibility attribute
Add in rc_version/rc_version_string functions, so external code using rcheevos as a shared library can obtain the version (as they might not be able to use the macros).
*
* #include <stdint.h>
*
* RC_CXX_GUARD_BEGIN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/mgba-emu/mgba/blob/3a5642fcb81d3c279f8f385828e95ca3029d527d/include/mgba-util/common.h#L9-L15

Some libraries do use a macro for this (well, mGBA is the only one I know on hand)

Copy link
Contributor Author

@CasualPokePlayer CasualPokePlayer Dec 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RetroArch apparently also does it

Not always.
https://github.com/libretro/RetroArch/blob/2980eb7e1296498305b9c047c82050ffd4d85778/libretro-common/include/libretro.h#L30-L32

And definitely not consistently.

$ grep -rnI "extern \"C\" {" * | grep -v deps | wc -l
462
$ grep -rnI RETRO_BEGIN_DECLS * | grep -v deps | wc -l
209

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The closest I can find to any sort of industry standard is this document for writing gnu libraries. It uses BEGIN_C_DECLS and END_C_DECLS, which do seem somewhat familiar, and googling for BEGIN_C_DECLS returns plenty of hits.

Would you be willing to change the defines to RC_BEGIN_C_DECLS and RC_END_C_DECLS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be willing to do that. I mainly did CXX_GUARD as I only remember mGBA doing this and that's what it used (although in retrospect this is more an exception than the norm)

not touching md5.h (probably needs more fixes overall, like the typedefs should use fixed width types)
@Jamiras Jamiras merged commit 3cadf84 into RetroAchievements:develop Dec 20, 2023
6 checks passed
@Jamiras Jamiras added this to the 11.1.0 milestone Dec 20, 2023
@CasualPokePlayer CasualPokePlayer deleted the rc_export branch December 20, 2023 02:09
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

Successfully merging this pull request may close these issues.

2 participants