Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Multiple definition of' error when including in multiple files. #63

Open
Lodevd opened this issue Dec 28, 2021 · 0 comments
Open

'Multiple definition of' error when including in multiple files. #63

Lodevd opened this issue Dec 28, 2021 · 0 comments

Comments

@Lodevd
Copy link

Lodevd commented Dec 28, 2021

When including this library in multiple files you get the the following error(s):

(.text+0x0): multiple definition of `Modbus::Modbus(unsigned char, Stream&, unsigned char)'

This is easily solved with the following modifications:

  1. Placing a "ifndef" around the header code.
    #ifndef MODBUS_RTU_H
    #define MODBUS_RTU_H
    ....
    #endif

  2. creating a ModbusRtu.cpp file to split definition from declaration.
    All code down from the next line must be moved to the .cpp file.
    /* PUBLIC FUNCTIONS________________________________________________ */

  3. and obviously include the header file at the top of the .cpp file. :)
    #include <ModbusRtu.h>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant