You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
inline specifier dissapeared in 2.5.0, causing compile error #42
Hi!
Why did you remove inline specifiers of methods in v2.5.0? They came in v2.2.0 simply dissapear after v2.3.0.
I am using Task class in my template class which is producing linking errors.
Each derived class giving me multiple definition error for each method of your library.
However I'd like to use features from v2.5.0, so i cant go back to v2.3.0.
Is there any chance to restore them?
The idea behind inlines was to make TS compatible with multiple tab scetches, which we achieved by other means (splitting .H files into definitions and implementation).
I don't have your use case in my scenarios, so never tested before release.
Could you please create an example sketch (similar to existing examples), and I will see how it should be resolved?.
I prepared an example.
Program contains a generic class as parent (TemplateClass) and 2 specialized, derived classes (DerivedClassA, DerivedClassB).
Generic class is header file only, has no implementation file. Also all template methods are inline by default! Each member class (Task in this case) must have the same structure. As long as ur lib contained inline specifier sketch compiled. (@2.3.0)
(explanation here)
TemplateClass
#ifndef CLASSTEMPLATE
#defineCLASSTEMPLATE
#include<TaskScheduler.h>//comment out this line to avoid linking errortemplate<typename T>
classTemplateClass {
public:voidsomeMethod(T input);
virtualvoidanotherDerivedMethod(T input)=0;
protected:
Task _taskToDo; //comment out this line to avoid linking error
};
template<typename T>
void TemplateClass<T>::someMethod(T input) {
//template class method implementation
}
#endif
Hi, Did you check the multi-tab example?
I think the issue is that you need to include TaskScheduler.h into main.cpp, and TaskSchedulerDeclarations.h into all the HPP files. Does that work?
Hi, I did.
Unfortunately it does not work with template classes. As soon as I instantiate a 2nd specialization of the generic class it throws linker error. Generic class must contain declaration only.
I modified TaskScheduler.h to make it work. All method got an inline specifier (as u did int 2.3.0) and it works just fine.
Activity
arkhipenko commentedon Dec 29, 2017
The idea behind inlines was to make TS compatible with multiple tab scetches, which we achieved by other means (splitting .H files into definitions and implementation).
I don't have your use case in my scenarios, so never tested before release.
Could you please create an example sketch (similar to existing examples), and I will see how it should be resolved?.
Cheers.
bedomarci commentedon Dec 29, 2017
I prepared an example.
Program contains a generic class as parent (TemplateClass) and 2 specialized, derived classes (DerivedClassA, DerivedClassB).
Generic class is header file only, has no implementation file. Also all template methods are inline by default! Each member class (Task in this case) must have the same structure. As long as ur lib contained inline specifier sketch compiled. (@2.3.0)
(explanation here)
TemplateClass
DerivedClassA
declaration - DerivedClassA.hpp
implementation - DerivedClassA.cpp
DerivedClassB - almost identical to DerivedClassA, but different specialization
declaration - DerivedClassB.hpp
implementation - DerivedClassB.cpp
main.cpp
environment:
Best,
Marci
arkhipenko commentedon Dec 30, 2017
Thanks. Will look into this after the holidays.
arkhipenko commentedon Jan 8, 2018
Hi, Did you check the multi-tab example?
I think the issue is that you need to include TaskScheduler.h into main.cpp, and TaskSchedulerDeclarations.h into all the HPP files. Does that work?
mutiltab example
bedomarci commentedon Jan 8, 2018
Hi, I did.
Unfortunately it does not work with template classes. As soon as I instantiate a 2nd specialization of the generic class it throws linker error. Generic class must contain declaration only.
I modified TaskScheduler.h to make it work. All method got an inline specifier (as u did int 2.3.0) and it works just fine.
arkhipenko commentedon Jan 9, 2018
Hi,
Please test 2.5.2 from the "testing" branch and use #define _TASK_INLINE compile directive
Does this fix the issue?
bedomarci commentedon Jan 9, 2018
Compiles with no error! Thank you!
arkhipenko commentedon Jan 9, 2018
OK. I will test a little more and update master branch later.