Skip to main content
jdcowpland
Associate III
June 9, 2015
Question

warning: ''__packed'' redefined [enabled by default]

  • June 9, 2015
  • 1 reply
  • 808 views
Posted on June 09, 2015 at 10:00

I'm getting the following message from my compiler:

 warning: ''__packed'' redefined [enabled by default]

which is defined in the usb_conf.h file from the USB_OTG library, and in the cdefs.h file from the gcc. Any ideas how to get rid of the message?
    This topic has been closed for replies.

    1 reply

    waclawek.jan
    Super User
    June 9, 2015
    Posted on June 09, 2015 at 10:40

    The root cause is that ST blatantly violates C99 7.1.3#1 (both ''All identifiers that begin with an underscore [...] are always reserved'' clauses) in all their libraries (and for that matter, ARM does the same in the CMSIS files it supplies). Here, they are partially innocent - the library had been apparently developed for the ARM compiler, and the redifinitions stem from attempt for a cheap porting.

    The real solution is to manually rewrite all __packed in the whole library for a name allowed in user namespace, e.g. PACKED (making sure it's an unique name of course). This is something ST ought to do really, so if you are in position they listen to you (i.e. you represent the >1M buying power), please push them to do so for others' benefit.

    The quick and dirty solution is to attempt to suppress the warning in command line, but as it's ''enabled by default'' it may be not a trivial undertaking - try to browse the warnings part of gcc documentation.

    JW