This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Difference between attributes of noinit declaration



I have code which uses __no_init in many places. I have defined in pre-defined macro

__no_init=__attribute__((noinit)).

 

In code __no_init is used to declare a variable like below in many places.

static volatile __no_init ABS_ ReadInfo; 

As per MSP430 Optimizing c/c++ compiler doc

The syntax of the GCC attributes is:

int x __attribute__((noinit));

As per doc attributes should be after variable. But in code i have before variable..

It doesn't give me any warnings/errors.

I want to know whether it is correct to use attribute befor variable name ?

Else i want to change all places in my code...

 

  • While all the GCC examples for variable attributes write the attribute after the variable name, I'm very confident you can also write the attribute before the variable, as you have done.  I'll get confirmation on that.

    I am a bit confused about ...

    vinoth s1 said:
    static volatile __no_init ABS_ ReadInfo;

    I presume ABS_ is the type of ReadInfo, i.e. int or long or whatever. If that presumption is correct, then this variable definition is fine as written.

    Thanks and regards,

    -George