Microchip-MPLAB-Harmony / core

Harmony 3 Core
https://onlinedocs.microchip.com/v2/keyword-lookup?keyword=MH3_core&redirect=true
Other
17 stars 12 forks source link

Missing #include in sys_debug #12

Closed dchirgwin closed 4 years ago

dchirgwin commented 4 years ago

The problem

The "sys_debug.h" file depends on SYS_DEBUG_USE_CONSOLE but that is defined in "configuration.h" which is not included.

The effect is that the macros SYS_MESSAGE, SYS_DEBUG_MESSAGE, etc. will behave differently depending on what other header files are included:

Example 1:

#include "configuration.h"
#include "system/debug/sys_debug.h"

void myCode1()
{
  SYS_MESSAGE("This works as expected");
}

Example 2:

#include "system/debug/sys_debug.h"

void myCode2()
{
  SYS_MESSAGE("This does NOT work as expected");
}

Example 3:

#include "system/debug/sys_console.h"
#include "system/debug/sys_debug.h"

void myCode3()
{
  // Very scary invisible side-effect
  SYS_MESSAGE("This works as expected because configuration.h is included in sys_console.h");
}

The fix

I think all that needs to happen is for "configuration.h" to be included within "sys_debug.h". The behaviour is then consistent, and controlled by the configuration options in all cases.

amitraddi commented 4 years ago

@dchirgwin Thank you for reporting the issue. It will be fixed in next release

dsettu commented 4 years ago

This issue is fixed in v3.7 release. Hence, closing the issue.