[ https://issues.apache.org/jira/browse/ZOOKEEPER-4556?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
George J Carrette updated ZOOKEEPER-4556: ----------------------------------------- Summary: function zoo_version_str (was: function zoo_version_str for determining what libzookeeper.so was loaded) > function zoo_version_str > ------------------------ > > Key: ZOOKEEPER-4556 > URL: https://issues.apache.org/jira/browse/ZOOKEEPER-4556 > Project: ZooKeeper > Issue Type: Improvement > Components: c client > Affects Versions: 3.8.0 > Reporter: George J Carrette > Priority: Major > Labels: api-addition > Fix For: 3.9.0 > > Original Estimate: 2h > Remaining Estimate: 2h > > A function zoo_version_str would be useful for the same reasons that > librdkafka has a rd_kafka_version_str, in short, for when a program has > dynamically loaded libzookeeper_mt.so and wants to verify that it provides > the expected api version that the calling program was compiled against. > It is true that zookeeper-native binary package usually contains the > /usr/include/zookeeper files but that is not always the case and even so > provides a more complex scanning issue than simply calling an api function. > Here is the full source code needed to implement this function as a patch to > 3.5 and earlier. > {code:java} > #define STR1(x) STR2(x) > #define STR2(x) #x > const char *zoo_version_str() { > return STR1(ZOO_MAJOR_VERSION) "." STR1(ZOO_MINOR_VERSION) "." > STR1(ZOO_PATCH_VERSION); > } {code} > This function would also be used by any language using a libffi style > solution, of which there are many. In this case you preprocess the > /usr/include/zookeeper files into an application binary interface (ABI) and > then at runtime you must ensure that your ABI matches the API version for the > dynamic library which you want to consume. > The implementation for the master branch and 3.6 and later is > {code:java} > const char *zoo_version_str() { > return ZOO_VERSION; > }{code} > > Pull request [https://github.com/apache/zookeeper/pull/1893] > > -- This message was sent by Atlassian Jira (v8.20.7#820007)