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

Should put extern "C" around public header #11

Closed
asveikau opened this issue Sep 28, 2022 · 0 comments
Closed

Should put extern "C" around public header #11

asveikau opened this issue Sep 28, 2022 · 0 comments
Assignees

Comments

@asveikau
Copy link
Collaborator

When mixing C and C++, it's customary to put after the include guard:

#if defined(__cplusplus)
extern "C" {
#endif

and at the end of the file:

#if defined(__cplusplus)
}
#endif

This tells the C++ compiler to not "name mangle" the symbols, i.e. to give them C linkage.

You don't need to do this around private headers involving C++ and classes etc. I would only suggest this for the public header.

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