1

We're working on a bigger embedded project, where we are using pre-compiled libraries. When compiling, lines where foreign code is used throw a huge amount of warnings. One occuring really often is

warning: ignoring packed attribute because of unpacked non-POD field '....'

This happens with gcc-arm-none-eabi-6-2017-q and Eclipse for embedded C/C++, version: 2020-09 (4.17.0).

I found multiple ways to get rid of warnings:

  1. Add Comment // @suppress ("warning ...."), which does not work in that case.
  2. As stated here, one can disable a specific warning using the warning number and -Wno-xxxx.
  3. We could disable the whole group to which a warning belongs, see the first list here. I added -Wpacked to the makefile just to see what happens, it added 48'000 warnings. So this is probably not our candidate.

Does anybody know the warning number/category for that one? Or how do disable it in any other way?

  • `-W...` enables warnings, to disable try `-Wno-...`, eg `-Wno-packed`. But did you try analysing the code where the warning is triggered? I doubt the warning is triggered for nothing. – rustyx Mar 18 '21 at 08:49
  • That's the point where it gets tricky. The foreign FW is a blackbox to us, we only see the headers. The message basically says "I did not leave away the padding because the non-POD field isn't packed and has padding", and results in a higher storage usage. Using `-Wno-packed` didn't help, but it should. I also stumbled upon [this](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58798) and thought it wouldn't apply to me because the bug is so old (2013). But apparently it's still not solved. – daVinciClaude Mar 18 '21 at 13:23
  • Just saw that we are mixing `#pragma pack` and `__attribute__((packed))`, which might lead to these warnings: [Bug 60972 - Mixing #pragma pack and __attribute__((packed)) leads to spurious warning](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60972) – daVinciClaude Mar 18 '21 at 13:27

0 Answers0