This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SEGGER Embedded Studio v6.20 compiler warning

Hi DevZone,

I recently updated my version of SEGGER Embedded Studio for ARM to v6.20. Now, warnings that were not shown before are caught.

I want to ignore the warning triggered specifically when giving reference to a member of a packed struct I am getting the following warning:

<taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Waddress-of-packed-member]>

 

Example:

typedef struct __attribute__((__packed__))
{
    uint16_t a;                   
    uint16_t b;                   
} ExampleStruct;

void ExampleFunction(uint16_t* var)
{
    // Place data at given pointer address
}

int main(void)
{
    ExampleStruct exampleStruct;

    ExampleFunction(&exampleStruct.a);
    ExampleFunction(&exampleStruct.b);

    return 0;
}

Is it possible to omit certain compiler warnings, or to specify to the compiler that I am doing this intentionally?

Parents Reply
  • Word is back from SEGGER.

    Apparently, when using a Nordic license for SEGGER, one has to use the community forums and not the direct support.

    https://forum.segger.com/

    However, I still got a pointer in the right direction from the Engineer who got back to me and was able to figure it out.

    Solution:

    1. Go to Project Options -> Code -> Compiler -> Additional C/C++ Compiler Options
    2. Make sure to chose  the "Common" build configuration if you want this for all build configurations. Alternatively select the specific build configuration of interest.
    3. Add the line -Wno-address-of-packed-member
    4. Save and rebuild

    Also, check out https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html for more options.

    Hope this helps someone. 

    Br. Casper

Children
No Data
Related