This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28379D: bug: including stdlib suppresses format warnings

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE,

Hi

I wasted a lot of time debugging, because I had used the wrong format specifier in a printf statement, resulting in printing the wrong number leading me on a goose chase.

This made we wonder why i did not get any warnings from the compiler about this. Checking that i had all the warning and remark things enabled, I was stilll not seeing the warning.

Made a new simple project to test and to report to TI about this. Suddenly i got the warnings as expected.....

Digging further into this I found that it was an include of an include of an include of an include that included stdlib.h, that was the culprit.

I have not made a zip for you but here is a simple recipe:

import the empty_driverlib project from C2000Ware.

Replace the content of empty_driverlib_main.c with this

//#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);
}

compile this file using the "Build selected files" option. And verify that you see two warnings about the format.

"C:\\ti\\ccs1220\\ccs\\tools\\compiler\\ti-cgt-c2000_22.6.0.LTS\\bin\\cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 -Ooff --include_path=C:/TI_workspaces/doodle/empty_driverlib_project --include_path=C:/TI_workspaces/doodle/empty_driverlib_project/device --include_path=C:/ti/C2000Ware_4_03_00_00/driverlib/f2837xd/driverlib --include_path=C:/ti/ccs1220/ccs/tools/compiler/ti-cgt-c2000_22.6.0.LTS/include --define=DEBUG --define=CPU1 --diag_suppress=10063 --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi --include_path=C:/TI_workspaces/doodle/empty_driverlib_project/CPU1_RAM/syscfg "..\\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

Now uncomment the first line with the `//#include <stdlib.h>`

Compile again and see that the warnings are now gone.

I am using CCS Version: 12.2.0.00009 

And C2000 compiler ti-cgt-c2000_22.6.0.LTS

I am compiling for the TMS320f28379D µC, but I do not expect it to be isolated to this.

Edit:

Note the order of include matters, if you include the stdlib after stdio, you get the warnings as expected.