Hi.
I was trying to compile this in C++:
........................ extern "C" { #include <nettle/rsa.h> }
int main () { exit (0); } ........................
But rsa.h includes gmp.h, and unfortunately, this won't work for C++ (at least not for g++) -- not even if declared 'extern "C"'. The <gmpxx.h> header should be used when using GMP from C++ programs.
If I remove the "include <gmp.h> from rsa.h, then I can compile, so long as I include gmpxx.h nefore rsa.h:
........................ extern "C" { #include <gmpxx.h> #include <nettle/rsa.h> // Removed #include <gmp.h> from this one }
int main () { exit (0); } ........................
It also happens with bignum.h, dsa.h and pkcs1.h.
It would be nice if we could call Nettle's rsa.h from C++. It would work with an #if:
#if defined(__cplusplus) #include <gmpxx.h> extern "C" { #else #include <gmp.h> #endif
. . /* The header declarations are here */ .
#if defined(__cplusplus) } #endif
But then it would be better to change all .h files so they could be directly used from C++, even those that do not include gmp.h:
#if defined(__cplusplus) extern "C" { #endif
Then, from C++, we'd just include all files as if they were C++ include files.
But you may also prefer to have specific C++ header files, like
rsaxx.h dsaxx.h pkcs1xx.h bignumxx.h
However, when calling from C++ we'd still need to have some headers inside an "extern "C"" block, and others not:
................. #extern "C" { include <nettle/yarrow.h> } #include <nettle/bignumxx.h> #include <nettle/dsaxx.h> .................
If there is interest, I could make a patch with either of these two solutions.
Thanks, J.