In c++, const have internal linkage by default. In c, const have external linkage by default.
We recently switched to explicitly declaring PANDA_CAN_CNT with external linkage (with the extern keyword) in order to comply with misra8.4. This does not affect anything in panda, since again in c const have external linkage by default and panda is a c project.
Because we are still defining variable in header (PANDA_CAN_CNT in can.h) and declaring them with external linkage now, we get redefinition errors when compiling pandad in openpilot because can.h is included in multiple translation units (pandad.cc, main.cc). This was not a problem before since pandad is a c++ process, which mean that all those variables were already declared with internal linkage.
In
c++
, const have internal linkage by default. Inc
, const have external linkage by default.We recently switched to explicitly declaring
PANDA_CAN_CNT
with external linkage (with theextern
keyword) in order to comply with misra8.4. This does not affect anything in panda, since again inc
const have external linkage by default and panda is ac
project.Because we are still defining variable in header (
PANDA_CAN_CNT
incan.h
) and declaring them with external linkage now, we get redefinition errors when compiling pandad in openpilot becausecan.h
is included in multiple translation units (pandad.cc
,main.cc
). This was not a problem before since pandad is ac++
process, which mean that all those variables were already declared with internal linkage.