[ABANDONED] Segger inttypes.h incorrectly defines SCNu8, error detected by code analysis

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [ABANDONED] Segger inttypes.h incorrectly defines SCNu8, error detected by code analysis

    The header file inttypes.h provided by Segger Embedded Studios does not correctly define SCNu8. The macro SCNu8 should be the vscanf formatter to read an uint8_t type. According to multiple sources online it is properly defined as:

    #define SCNu8 'hhu'
    decimal scanf format for uint8_t


    However in SES inttypes.h it is defined:

    // %u
    #define SCNu8 "u"
    #define SCNu16 __RAL_SCN_16_PREFIX "u"
    #define SCNu32 __RAL_SCN_32_PREFIX "u"
    #define SCNu64 "llu"


    This results in the static analysis tool generating an warning:

    format specifies type 'unsigned int *' but the argument has type 'uint8_t *' (aka 'unsigned char *') [clang-diagnostic-format]

    when the code has
    uint8_t log_severity_lvl;
    sscanf( argv[1], "%"SCNu8, &log_severity_lvl ) );
  • Hello,

    Thank you for your inquiry.
    Could you clarify which version of Embedded Studio you are using. What toolchain? Which run time library?

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.