-
Notifications
You must be signed in to change notification settings - Fork 211
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
how to use it without boost? #110
Comments
I guess given C++17 has |
it could be opted out at compile time with #if (__cplusplus >= 201703L)
... use std
#else
... boost
#endif I actually think this would be a good PR |
This should actually go into the config.h file so that if you build the library, then you must use whatever you used while building. Otherwise you could build cppkafka using some compiler on C++14 (using boost), then you build your application using C++17 and link against the C++14 .so and then your code will go kaboom. |
You can actually catch this error at link time and prevent linking to mismatched libraries even w/o a config file or cmake flags. //in the public cppkafka .h file
#if (__cpluplus >= 201703L)
extern int CPPKAFKA_COMPILED_STL;
static const int MY_LIBRARY_VERSION = CPPKAFKA_COMPILED_STL;
... stl include headers
#else
extern int CPPKAFKA_COMPILED_BOOST;
static const int MY_LIBRARY_VERSION = CPPKAFKA_COMPILED_BOOST;
... boost include headers
#endif
// inside any cppkafka .cpp file
#if (__cpluplus >= 201703L)
int CPPKAFKA_COMPILED_STL;
#else
int CPPKAFKA_COMPILED_BOOST;
#endif Now if the cppkafka library was built with a c++11 compiler and the app with c++17, the app won't link as CPPKAFKA_COMPILED_STL is not defined. Same technique can be used to tag ABI incompatible versions. |
If you build the library on C++14 and use boost, then you use C++17 on your application and you're using boost then you want this to build as it can do that just fine. I wouldn't expect my code to fail to build if I build in C++17 when the library was built using C++14. |
The code above was an example...instead of using #defines on the compiler version it can simply be a #define USE_BOOST which in turn could be set in the cmake file. Or a combination of both. |
Could it be "fixed" adding these options in the cmake file within the next release? |
Any luck with this. I would like to keep it without boost. |
boost is very big, why not do not depend on it?
The text was updated successfully, but these errors were encountered: