jmamma / MCL

MCL firmware for the MegaCommand MIDI Controller.
BSD 2-Clause "Simplified" License
53 stars 9 forks source link

non-C++ functions in memory.h use C++-only macro #115

Closed jwakely closed 3 years ago

jwakely commented 4 years ago

Apologies if I'm misunderstanding something, but it looks like the functions outside the #ifdef __cplusplus block in avr/cores/megacommand/memory.h won't actually compile for C, because they use the select_bank macro which is only defined for C++.

e.g.

#endif// __cplusplus

ALWAYS_INLINE() extern inline void memcpy_bank1(volatile void *dst, volatile const void *src, uint32_t len) {
  select_bank(1);
  memcpy(dst, src, len);
}

This uses select_bank(1) which is not defined unless __cplusplus is defined.

Do those functions actually need to get called by non-C++ code, or can they just be moved inside the #ifdef __cplusplus block ?

jmamma commented 4 years ago

Do those functions actually need to get called by non-C++ code, or can they just be moved inside the #ifdef __cplusplus block ?

Good catch. Those other functions should be moved within the C++ guard. We're currently getting away with it because no C code is calling them.

--

@jwakely thanks for checking out our project. I suspect you'll find other idiosyncrasies 😄

jwakely commented 4 years ago

OK thanks for confirming. I'll send a pull request to move them into the guarded block.

Thanks for the project! I'm considering building a megacommand so thought I'd have a look at the code.

yatli commented 3 years ago

@jwakely should be fixed with ba2510b6