relic-toolkit/relic

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

ghoshbishakh opened this issue · 1 comments

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.

Green signal! Please submit a Pull Request :)