Usage of C style cast operations instead of C++ style cast operations
Issue #21
resolved
Is there any reason for using C style cast operations in the code base instead of C++ style cast operations(like reintrepret_cast<datatype> etc.) ? Will it cause any runtime error if I change all the C style cast operations to C++ style cast operations ?
For example , can this line be changed to support C++ style casting ?
const MsgGearReport *ptr = (const MsgGearReport*)msg->data.elems;
Comments (2)
-
-
- changed status to resolved
- Log in to comment
The CAN message structures do not use any C++ specific features (no methods or inheritance), so the C style cast was used. Also, this C style cast is shorter (fewer characters).
Yes, you could change all of the pointer casts to the C++ style reinterpret_cast<datatype>. Do you have a specific reason to make this change? Otherwise I'm not sure it's worth branching from the main code base for this small change.