herumi / mcl

a portable and fast pairing-based cryptography library
BSD 3-Clause "New" or "Revised" License
450 stars 151 forks source link

Checking if library has been initialized #176

Closed aguycalled closed 1 year ago

aguycalled commented 1 year ago

Is there any way (without storing the return value of the init function for future use) to determine whether the library has been correctly initialized?

Thanks.

herumi commented 1 year ago

How about defining a global flag?

std::atomic<bool> g_is_mcl_initialized;
bool is_mcl_initialized() { return g_is_mcl_initialized; }

if (initPairing(...)) {
  g_is_mcl_initialized = true;
}