← Back to team overview

kicad-developers team mailing list archive

Re: Damned the 'undefined global constructor order'

 

On Mon, Jun 09, 2014 at 03:42:23PM -0500, Dick Hollenbeck wrote:
> You could also create a new constructor that actually takes an int64_t bitmap, and use

For the builtin layers could work, however in general there could be
more than 64.

> GetLayerMask() to build it.
> 
> However I would rename GetLayerMask() to something more concise:

GetLayerMask is no more, however I got the message.

> 
> const LAYER_SET LAYER_SET::IMPORTANT_SET = LMSK( LAYER_CU_FRONT ) | LMSK( LAYER_CU_BACK );
> P.S. I sort of LAYER_SET better than LAYER_MSK as a type name.

LSET then is even better :D

> const LAYER_SET CU_EXTERNAL = LAYER_SET().set( LAYER_CU_FRONT ).set( LAYER_CU_BACK );


My problem was another one... ATM I can already write

const LSET CU_EXTERNAL = // <<< see, I like it :D
    LAYER_CU_FRONT | LAYER_CU_BACK;

but in another place I can't say

const LSET MORE_CU = LAYER_CU_WHATEVER | CU_EXTERNAL;

since the MORE_CU initialization *could* be run before CU_EXTERNAL's
one. AFAIK there is a gcc attribute to order them (but it's a PITA to
track dependencies by hand).

The current 'best' solution I've found is

LSET CU_EXTERNAL()
{
    static const LSET this_value = LAYER_CU_FRONT | LAYER_CU_BACK;
    return this_value;
}

since it's guaranteed that this_value constructor get run on the first
call, and only then.

-- 
Lorenzo Marcantonio
Logos Srl


Follow ups

References