Closed ghost closed 2 years ago
This is how you do it:
https://github.com/arkhipenko/TaskScheduler/tree/master/examples/Scheduler_example27_PlatformIO [https://opengraph.githubassets.com/6b9ea2568b35c75afe9cd1a947da50e9dd93fb6b083d59db82f546f27a4511a8/arkhipenko/TaskScheduler]https://github.com/arkhipenko/TaskScheduler/tree/master/examples/Scheduler_example27_PlatformIO TaskScheduler/examples/Scheduler_example27_PlatformIO at master · arkhipenko/TaskSchedulerhttps://github.com/arkhipenko/TaskScheduler/tree/master/examples/Scheduler_example27_PlatformIO Cooperative multitasking for Arduino, ESPx, STM32, nRF and other microcontrollers - TaskScheduler/examples/Scheduler_example27_PlatformIO at master · arkhipenko/TaskScheduler github.com
From: sami-theion @.> Sent: Wednesday, May 18, 2022 12:43 PM To: arkhipenko/TaskScheduler @.> Cc: Subscribed @.***> Subject: [arkhipenko/TaskScheduler] #include error from c++ compiler due to multiple definition error (Issue #143)
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
— Reply to this email directly, view it on GitHubhttps://github.com/arkhipenko/TaskScheduler/issues/143, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AACMMTINQCA5D6I2MWPOU7TVKUM2ZANCNFSM5WJCW6TQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>
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!
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 aTaskScheduler.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>
."
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