Focus serial template version of send(...) - call by value

Using call by reference in FocusSerial::send(...) and
FocusSerial::sendRaw(...) causes linker errors due to
undefined symbols if constexpr constants are passed to the
methods.

This is because if a constexpr value is bound to a reference
this is the same as taking the address of the value. Thus,
the compiler has to generate an instance. Some constants
like e.g. FocusSerial::NEWLINE do not come with an
instance.

This seems not to cause problems with avr-gcc up to now
but generates linker errors during virtual compiles with later gcc
versions (e.g. gcc 8.3.0).

This change does not incur any additional overhead as
all version of FocusSerial's send methods are already inlined,
and the templated versions root to the non-template versions of the send
methods that only accept call-by-value anyway.

Signed-off-by: Florian Fleissner <florian.fleissner@inpartik.de>
pull/729/head
Florian Fleissner 5 years ago committed by Jesse Vincent
parent c864e78e94
commit 4c2e0a7635
No known key found for this signature in database
GPG Key ID: CC228463465E40BC

@ -45,14 +45,14 @@ class FocusSerial : public kaleidoscope::Plugin {
Kaleidoscope.serialPort().print(SEPARATOR); Kaleidoscope.serialPort().print(SEPARATOR);
} }
template <typename Var, typename... Vars> template <typename Var, typename... Vars>
void send(Var v, const Vars&... vars) { void send(Var v, Vars... vars) {
send(v); send(v);
send(vars...); send(vars...);
} }
void sendRaw() {} void sendRaw() {}
template <typename Var, typename... Vars> template <typename Var, typename... Vars>
void sendRaw(Var v, const Vars&... vars) { void sendRaw(Var v, Vars... vars) {
Kaleidoscope.serialPort().print(v); Kaleidoscope.serialPort().print(v);
sendRaw(vars...); sendRaw(vars...);
} }

Loading…
Cancel
Save