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

Wrap headers with extern "C" for C++ compatibility #234

Closed
ghoshbishakh opened this issue May 4, 2022 · 1 comment · Fixed by #273
Closed

Wrap headers with extern "C" for C++ compatibility #234

ghoshbishakh opened this issue May 4, 2022 · 1 comment · Fixed by #273

Comments

@ghoshbishakh
Copy link

The headers are not wrapped with extern "C" {} , which causes major problems when using with a C++ project. An example follows:

extern "C" {
#include <relic/relic.h>
}

This code internally also includes gmp. (if relic is built with gmp).
Now, since it is a c++ code, #ifdef __cplusplus segments are enabled causing it to import some C++ specific codes (specifically templates).

A hack I am using is to import gmp above that. Once it is imported, the header guards prevent relic to reimport it and thus avoiding the error :)

@abhimp suggested to wrap each relic header file with extern "C".
Example:

relic/src/md/blake2.h

Lines 27 to 29 in 9206ae5

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

If you @dfaranha give the green signal I will work on this next week.

@dfaranha
Copy link
Contributor

dfaranha commented May 9, 2022

Green signal! Please submit a Pull Request :)

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 a pull request may close this issue.

2 participants