Uploaded image for project: 'Embedded Software & Tools'
  1. Embedded Software & Tools
  2. EXT_EP-11095

Inconsistent definition of ATTRIBUTE macro for non-LLVM toolchains

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium

      A customer reports that the following code yields compile-time warnings regarding incompatible arguments on the format strings:

      #include <stdint.h>
      #include <stdio.h>
      
      void f(void){    
          uint32_t u32var=0;    
          int32_t s32var=0;
          
          printf("%i", u32var);    
          printf("%i", s32var);
      }

      result:

      "C:\\ti\\ccs1220\\ccs\\tools\\compiler\\ti-cgt-c2000_22.6.0.LTS\\bin\\cl2000" -v28 -ml -mt "..\\empty_driverlib_main.c" 
      "..\empty_driverlib_main.c", line 10: warning #183-D: argument is incompatible with corresponding format string conversion
      "..\empty_driverlib_main.c", line 11: warning #183-D: argument is incompatible with corresponding format string conversion 

      whereas the same code with stdlib.h included first does not yield any compile-time warning.

      #include <stdlib.h>
      #include <stdint.h>
      #include <stdio.h> 
      
      void f(void){    
          uint32_t u32var=0;    
          int32_t s32var=0; 
          
          printf("%i", u32var);    
          printf("%i", s32var);
      }

      The inclusion of stdlib.h first affects whether the format function attribute is applied to the printf routine in stdio.h.  This attribute will force the compiler to check that the function is called with a format string that uses format specifiers that are allowed, and that arguments match the format string. If the compiler encounters an issue with this check, a warning diagnostic will be emitted at compile-time.  The attribute is not being applied consistently depending on the order of inclusion of header files.

            syncuser TI User
            syncuser TI User
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: