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

#include error from c++ compiler due to multiple definition error #143

Closed
ghost opened this issue May 18, 2022 · 3 comments
Closed

#include error from c++ compiler due to multiple definition error #143

ghost opened this issue May 18, 2022 · 3 comments

Comments

@ghost
Copy link

ghost commented May 18, 2022

first i want to thank you for the great work.
As the cpp compiler seems not happy only with header files, it complains whenever i include the "taskScheduler.h" in other header than main.cpp
As far i know it need to find the implementation files for your library. otherwise it complains about multiple definitinons ...
Is there any version/ branch where we can find .h and .cpp from yours.
Thank you

@arkhipenko
Copy link
Owner

arkhipenko commented May 18, 2022 via email

@Jozott00
Copy link

Jozott00 commented Jul 8, 2022

For everyone who also has the linking problem with TaskScheduler.h:

It is important that only one file with the #define TaskScheduler.h macro is compiled! Therefore the PlatformIO example has a TaskScheduler.cpp file with just this macro.

All other files (including main.cpp) that have to use the library must use #define TaskSchedulerDeclarations.h to get linked without an error!

@MaffooClock
Copy link

This has been answered in several other issues, but since Google brought me here and Jozott00's comment isn't accurate, I figured I'd add some clarification.

It is important that only one file with the #define TaskScheduler.h macro is compiled! Therefore the PlatformIO example has a TaskScheduler.cpp file with just this macro.

He means "only one file can have #include <TaskScheduler.h>"...

All other files (including main.cpp) that have to use the library must use #define TaskSchedulerDeclarations.h to get linked without an error!

...and "all other files must use #include <TaskSchedulerDeclarations.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

3 participants