[CLN-list] Global static class instance

Richard B. Kreckel kreckel at in.terlu.de
Tue Jan 17 23:38:30 CET 2023


Hi,

On 1/15/23 15:59, Jan Rheinländer wrote:
> in file include/cln/lfloat_class.h there is the line
> 
>      static cl_LF_globals_init_helper cl_LF_globals_init_helper_instance;
> 
> Now as far as I can see this will instantiate an instance of class 
> cl_LF_globals_init_helper in every object file that includes the header 
> (https://stackoverflow.com/questions/11967502/okay-to-declare-static-global-variable-in-h-file seems to support this).
> 
> Wouldn't it be better to replace static by extern and define the 
> instance in some .cc file?

This is not POD (plain old data).

The point of this code is explained in 7f619754e2 by Alexey Sheplyakov.

All my best,
   -richy.


More information about the CLN-list mailing list