On Sun, 2018-03-11 at 00:15 +0100, Niels Möller wrote:
> so that the initializer is evaluated exactly once, after the first entry
> to the function, but before any thread uses the value (likely generating
> code using pthread_once). Has anything like that made it into recent C
__attribute__ ((constructor)) is one possible solution,
if you isolate your critical init part in a function.
About it being in a standard or not, I don't know.
But it's pretty common, and handled by clang and gcc.
So it should be rather reliable.
gmp-devel mailing list