jhu-cisst / cisst

JHU ERC CISST Library
http://github.com/jhu-cisst/cisst/wiki
Other
64 stars 47 forks source link

fixing explicit specialization after implicit instantiation of cmnCla… #56

Closed rhgmn closed 6 years ago

rhgmn commented 6 years ago

…ssServicesInstantiate in TEMPLATED_INTERNAL class register macro

adeguet1 commented 6 years ago

Any reason you had to swap these two? Warning or error from a compiler or runtime error? I'll have to compile cisst with quite a few compilers to make sure this doesn't break anything.

rhgmn commented 6 years ago

For an external project, a linking error for mtsGenericObjectProxy lead me to create a compilation unit with the following in it:

include <cisstMultiTask/mtsFunctionWrite.h>

include <cisstMultiTask/mtsGenericObjectProxy.h>

typedef mtsGenericObjectProxy tempType; CMN_IMPLEMENT_SERVICES_TEMPLATED(tempType);

Doing this gave me the following compiler error (llvm 9.0.0/clang-900.0.39.2):

/Users/hegemr1/src/saw/snake-optimizer/controller/ mtsGenericObjectProxyInstantiations.cpp:6:1: error: explicit specialization of 'cmnClassServicesInstantiate<mtsGenericObjectProxy

' after instantiation CMN_IMPLEMENT_SERVICES_TEMPLATED(tempType); ^ /usr/local/include/cisstCommon/cmnClassRegisterMacros.h:301:9: note: expanded from macro 'CMN_IMPLEMENT_SERVICES_TEMPLATED' CMN_IMPLEMENT_SERVICES_TEMPLATED_INTERNAL(className, 0, className) ^ /usr/local/include/cisstCommon/cmnClassRegisterMacros.h:292:24: note: expanded from macro 'CMN_IMPLEMENT_SERVICES_TEMPLATED_INTERNAL' cmnClassServicesBase cmnClassServicesInstantiate(void) \ ^ /Users/hegemr1/src/saw/snake-optimizer/controller/ mtsGenericObjectProxyInstantiations.cpp:6:1: note: implicit instantiation first required here /usr/local/include/cisstCommon/cmnClassRegisterMacros.h:301:9: note: expanded from macro 'CMN_IMPLEMENT_SERVICES_TEMPLATED' CMN_IMPLEMENT_SERVICES_TEMPLATED_INTERNAL(className, 0, className) ^ /usr/local/include/cisstCommon/cmnClassRegisterMacros.h:281:51: note: expanded from macro 'CMN_IMPLEMENT_SERVICES_TEMPLATED_INTERNAL' static cmnClassServicesBase classServices = cmnClassServicesInstantiate(); \ ^ 1 error generated. make[2]: [CMakeFiles/mtsGenericObjectProxyLib.dir/controller/ mtsGenericObjectProxyInstantiations.cpp.o] Error 1 make[1]: [CMakeFiles/mtsGenericObjectProxyLib.dir/all] Error 2 make: *** [all] Error 2

I believe this is valid after reading https://stackoverflow. com/questions/7774188/explicit-specialization-after-instantiation

2018-05-15 11:54 GMT-04:00 Anton Deguet notifications@github.com:

Any reason you had to swap these two? Warning or error from a compiler or runtime error?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jhu-cisst/cisst/pull/56#issuecomment-389218595, or mute the thread https://github.com/notifications/unsubscribe-auth/AKR8RKsQsZ1MEmT375QliuNWiaA2pC-iks5tyvovgaJpZM4T_qim .