AnsweredAssumed Answered

S12Z: __attribute__ ((aligned (4))) has no effect

Question asked by Pascal BRAND on Aug 23, 2017
Latest reply on Sep 19, 2017 by ZhangJennie

Hello,

 

Using CodeWarrior for MCU, v10.7, on S12Z target, I am not able to aligned global variables as specified in the documentation:

 

#pragma cpp1x on
int foo __attribute__ ((aligned (4)));
void main(void) {
    static_assert(__alignof__(foo) == 1, "SHOULD BE WRONG"); /* compilation OK. But it should fail */
    static_assert(__alignof__(foo) == 4, "SHOULD BE OK"); /* compilation failed. But it should be ok? */
}

 

compiled with

 

mwccs12lisa.exe alignment.c

 

results in the compilation error

 

Compiler:
# File: alignment.c
# --------------------
# 5: static_assert(__alignof__(foo) == 4, "SHOULD BE OK"); /* compilation failed. But it should be ok? */
# Error: ^^^^^^^^^^^^^^
# static assert check 'SHOULD BE OK' failed

 

What did I miss?

 

Thanks for your support,
Pascal.

Outcomes