Tool/software: TI C/C++ Compiler
Using TI's C2000 C Compiler, like this:
/opt/ti/ti-cgt-c2000_16.9.7.LTS/bin/cl2000 \
-v28 \
-ml \
-mt \
--float_support=fpu32 \
-Ooff \
-g \
--advice:performance=all \
--issue_remarks \
--check_misra=3,8.1,8.2,8.11,8.12,9.1,9.2,9.3,12.1,12.2,12.3,12.7,12.8,12.9,12.13,13.1,13.2,13.3,14.1,14.2,14.3,15.2,15.3,15.4,15.5,16.5,16.7,16.8,16.9,19.1,19.2,19.3,19.11,19.15,19.16,19.17,20.1,20.2 \
--misra_advisory=error \
--misra_required=error \
--define=xdc__strict \
--emit_warnings_as_errors \
--include_path=/opt/ti/ti-cgt-c2000_16.9.7.LTS/include \
--include_path=include \
--c_file=logger.c \
--diag_warning=225 \
--c99 \
--diag_wrap=off \
--output_file=logger.c.obj
Where "stdio.h" is included in the source file, I get these warnings:
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 65: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("size_t")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 79: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("FILE")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 94: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("fpos_t")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 131: error: (MISRA-C:2004 20.1/R) Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined ("_IOFBF")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 132: error: (MISRA-C:2004 20.1/R) Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined ("_IOLBF")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 133: error: (MISRA-C:2004 20.1/R) Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined ("_IONBF")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 154: error: (MISRA-C:2004 20.1/R) Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined ("BUFSIZ")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 156: error: (MISRA-C:2004 20.1/R) Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined ("FOPEN_MAX")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 157: error: (MISRA-C:2004 20.1/R) Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined ("FILENAME_MAX")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 158: error: (MISRA-C:2004 20.1/R) Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined ("TMP_MAX")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 160: error: (MISRA-C:2004 20.1/R) Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined ("stdin")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 161: error: (MISRA-C:2004 20.1/R) Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined ("stdout")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 162: error: (MISRA-C:2004 20.1/R) Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined ("stderr")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 164: error: (MISRA-C:2004 20.1/R) Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined ("L_tmpnam")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 168: error: (MISRA-C:2004 20.1/R) Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined ("SEEK_SET")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 169: error: (MISRA-C:2004 20.1/R) Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined ("SEEK_CUR")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 170: error: (MISRA-C:2004 20.1/R) Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined ("SEEK_END")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 173: error: (MISRA-C:2004 20.1/R) Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined ("NULL")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 177: error: (MISRA-C:2004 20.1/R) Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined ("EOF")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 203: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("remove")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 204: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("rename")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 205: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("tmpfile")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 206: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("tmpnam")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 211: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("fclose")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 212: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("fopen")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 214: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("freopen")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 217: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("setbuf")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 219: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("setvbuf")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 222: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("fflush")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 227: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("fprintf")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 230: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("fscanf")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 233: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("printf")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 235: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("scanf")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 237: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("sprintf")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 243: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("sscanf")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 246: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("vfprintf")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 252: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("vprintf")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 256: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("vsprintf")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 273: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("fgetc")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 274: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("fgets")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 276: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("fputc")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 277: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("fputs")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 279: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("getc")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 280: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("getchar")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 281: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("gets")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 282: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("putc")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 283: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("putchar")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 284: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("puts")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 285: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("ungetc")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 290: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("fread")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 293: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("fwrite")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 300: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("fgetpos")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 302: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("fseek")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 304: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("fsetpos")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 306: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("ftell")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 307: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("rewind")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 312: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("clearerr")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 313: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("feof")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 314: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("ferror")
"/opt/ti/ti-cgt-c2000_18.1.2.LTS/include/stdio.h", line 315: error: (MISRA-C:2004 20.2/R) The names of standard library macros, objects and functions shall not be reused ("perror")
Looking at some of the other standard library headers, I've seen these pragmas that are meant to deal with this:
#pragma diag_push
#pragma CHECK_MISRA("-20.1") /* standard headers must define standard names */
#pragma CHECK_MISRA("-20.2") /* standard headers must define standard names */
#pragma CHECK_MISRA("-19.7") /* macros required for implementation */
#pragma CHECK_MISRA("-19.10") /* need types as macro arguments */
These are not present in "stdio.h". If I add them manually, I can disable these warnings.
Is this an oversight or what's the rationale for leaving these out of that particular header?
I didn't check all of the other standard header files, but "stdio.h" is definitely affected.