When I enable this define for the debug
#define _DEBUG_INFO_TRACE_LEVEL_
#define _HOST_DEBUG_
there is a compilation problem,
#define DEBUG_LOG_TRACE(x) printf("\n%s",x);
the ; is an error because in the rest of the code when used DEBUG_LOG_TRACE there is always
...example code in host_main.c...
DEBUG_LOG_TRACE("_usb_host_init host state malloc failure");
with ;
Hello, it's not a bug, but for cleaner code it couldnt be there, I agree.
It's not a bug per se unless the "DEBUG_LOG_TRACE("_usb_host_init host state malloc failure");" is used
inside of an if (or else, for, while,...) without braces.
I never use if's without braces so I dont have this issue thoug :smileyhappy:.
The DEBUG_LOG_TRACE could be improved by surrounding it with a do { .... } while (0) construct
(some hide that behind another set of macros). Also I would suggest to use braces around all macro arguments whenever possible, and I would not use printf but calls to fputc('\n', stdout); fputs((x), stdout); to avoid the missing argument check due to the open argument signature of printf.
Maybe using stderr instead of stdout might be considered as well.
I personally think that printf should not be used in conditional bracket as the return value from printf is not defined in MQX. You can use DEBUG_LOG_TRACE inside { } parentheses. DEBUG_LOG_TRACE is just a macro to put down result of operation in debug state- if you don't like it, you can redefine it. For nowadays purpose, it is sufficient.