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

Multiple Inclusion protection overlaps with C++ compatibility #18

Closed dchirgwin closed 4 years ago

dchirgwin commented 4 years ago

Maybe an obscure one, but I'm pretty sure it's an error.

In the APP template "app.h.ftl" you have the usual protection for multiple inclusion: Lines 23,34

#ifndef _${APP_TASK_NAME?upper_case}_H
#define _${APP_TASK_NAME?upper_case}_H

and a closing #endif on line 177

#endif /* _${APP_TASK_NAME?upper_case}_H */

There is also a macro for C/C++ compatibility. See lines 38-44

// DOM-IGNORE-BEGIN
#ifdef __cplusplus  // Provide C++ Compatibility

extern "C" {

#endif
// DOM-IGNORE-END

and that is closed in lines 179-183

//DOM-IGNORE-BEGIN
#ifdef __cplusplus
}
#endif
//DOM-IGNORE-END

The problem is that these two clauses overlap. I know that the structure of a Harmony 3 project makes this unlikely, but if there was ever an attempt a multiple inclusion from a C++ file, there would be a dangling closing brace causing a compiler error.

The simple fix is to move the multiple inclusion `#endif' from line 177 (before the C++ macro) to line 184 (after the C++ macro).

amitraddi commented 4 years ago

Hi @dchirgwin Thanks for reporting the issue. This is already taken care and will be part of next release in around 2 weeks