I'm working on a project using the MODBUS2 lib, and I want to add the FatFs lib to it to interface with an SD card. Both libraries use identifier SHORT
for short
and int
respectively, and the compiler throws this error:
#258 invalid redeclaration of type name "SHORT"
How can I work around this?
You need to restructure your project in such a way that no translation unit of your library would have to include headers from both libraries (translation unit is a fancy name for a C file).
One approach is to write your own thin "wrapper" functions around MODBUS2 and FatFs functionality. Each wrapper would have to include headers for the library that it wraps, so there would be no compile-time collision. Then the main module of your library would program to your "wrappers", without including MODBUS2 or FatFs headers at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With