Compiler warnings when SDK_DEBUGCONSOLE == DEBUGCONSOLE_DISABLE

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Compiler warnings when SDK_DEBUGCONSOLE == DEBUGCONSOLE_DISABLE

653 Views
r_strassburg
Contributor I

In the SDK for the LPC55S69 you get compiler warnings if SDK_DEBUGCONSOLE is defined as DEBUGCONSOLE_DISABLE. This is because in fsl_debug_console.h the PRINTF macro (as well as SCANF, etc.) is defined as an empty string in that case, leaving the arguments standing for the compiler to interpret. In order to prevent this, the macros need to be defined as callable, e.g.

#define PRINTF(format, ...)

etc.

0 Kudos
3 Replies

596 Views
FelipeGarcia
NXP Employee
NXP Employee

Hello Roger,

 

You are correct, when you select SDK_DEBUGCONSOLE = 2, it represents disable debugconsole function. Please keep in mind that if you want to enable debug console you can do it from the Quickstart Panel in Quick Settings > SDK Debug Console.

 

Best regards,

Felipe

0 Kudos

596 Views
r_strassburg
Contributor I

Hello Felipe,

I understand that. The problem is that when you do that, PRINTF() calls

will cause compiler warnings because disabling console output redefines

PRINTF to be an empty string, but the arguments passed to it remain in

the source file to get compiled, resulting in the warning. For example,

code containing this PRINTF call:

PRINTF("this is a format string to  print out an integer\n", 1);

will expand to either

DbgConsole_Printf("this is a format string to  print out an integer\n", 1);

if SDK_DEBUGCONSOLE == DEBUGCONSOLE_REDIRECT_TO_SDK,

or

printf("this is a format string to  print out an integer\n", 1);

if SDK_DEBUGCONSOLE == DEBUGCONSOLE_REDIRECT_TO_TOOLCHAIN.

But when you set SDK_DEBUGCONSOLE to DEBUGCONSOLE_DISABLE, it expands to

this:

("this is a format string to  print out an integer\n", 1);

which causes a compiler warning. What it should compile to is this:

;

To get rid of the warnings in this case, instead of defining printf as

an empty string:

#define PRINTF

in which case the above example expands to the orphan argument list in

the example above

it needs to be defined as a macro with variadic arguments:

#define PRINTF(format, ...)

This will cause the entire PRINTF call, including arguments to be

replaced with a null string.

Best regards,

Roger

0 Kudos

596 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Roger,

 

Yes, you are correct. You could redefine PRINTF like that to bypass the warnings. Thanks a lot for your report and feedback. We will take this into consideration for future releases.

 

Best regards,

Felipe

0 Kudos