diff --git a/protobuf-c/libprotobuf-c.sym b/protobuf-c/libprotobuf-c.sym index 484608e..9726d32 100644 --- a/protobuf-c/libprotobuf-c.sym +++ b/protobuf-c/libprotobuf-c.sym @@ -4,7 +4,6 @@ global: protobuf_c_default_allocator; protobuf_c_enum_descriptor_get_value; protobuf_c_enum_descriptor_get_value_by_name; - protobuf_c_major; protobuf_c_message_check; protobuf_c_message_descriptor_get_field; protobuf_c_message_descriptor_get_field_by_name; @@ -14,11 +13,12 @@ global: protobuf_c_message_pack; protobuf_c_message_pack_to_buffer; protobuf_c_message_unpack; - protobuf_c_minor; protobuf_c_service_descriptor_get_method_by_name; protobuf_c_service_destroy; protobuf_c_service_generated_init; protobuf_c_service_invoke_internal; + protobuf_c_version; + protobuf_c_version_number; local: *; }; diff --git a/protobuf-c/protobuf-c.c b/protobuf-c/protobuf-c.c index cc698c4..788e390 100644 --- a/protobuf-c/protobuf-c.c +++ b/protobuf-c/protobuf-c.c @@ -84,8 +84,19 @@ #define ASSERT_IS_SERVICE_DESCRIPTOR(desc) \ assert((desc)->magic == PROTOBUF_C_SERVICE_DESCRIPTOR_MAGIC) -unsigned protobuf_c_major = PROTOBUF_C_MAJOR; -unsigned protobuf_c_minor = PROTOBUF_C_MINOR; +/* --- version --- */ + +const char * +protobuf_c_version(void) +{ + return PROTOBUF_C_VERSION; +} + +uint32_t +protobuf_c_version_number(void) +{ + return PROTOBUF_C_VERSION_NUMBER; +} /* --- allocator --- */ diff --git a/protobuf-c/protobuf-c.h b/protobuf-c/protobuf-c.h index 437dab4..e731fb8 100644 --- a/protobuf-c/protobuf-c.h +++ b/protobuf-c/protobuf-c.h @@ -58,14 +58,6 @@ #define PROTOBUF_C_OFFSETOF(struct, member) offsetof(struct, member) -/* The version of protobuf-c you are compiling against. */ -#define PROTOBUF_C_MAJOR 0 -#define PROTOBUF_C_MINOR 16 - -/* The version of protobuf-c you are linking against. */ -extern unsigned protobuf_c_major; -extern unsigned protobuf_c_minor; - #if defined(_WIN32) && defined(PROTOBUF_C_USE_SHARED_LIB) # ifdef PROTOBUF_C_EXPORT # define PROTOBUF_C_API __declspec(dllexport) @@ -78,6 +70,39 @@ extern unsigned protobuf_c_minor; PROTOBUF_C_BEGIN_DECLS +/** + * Get the version of the protobuf-c library. Note that this is the version of + * the library linked against, not the version of the headers compiled against. + * + * \return A string containing the version number of protobuf-c. + */ +PROTOBUF_C_API +const char * +protobuf_c_version(void); + +/** + * Get the version of the protobuf-c library. Note that this is the version of + * the library linked against, not the version of the headers compiled against. + * + * \return A 32 bit unsigned integer containing the version number of + * protobuf-c, represented in base-10 as (MAJOR*1E6) + (MINOR*1E3) + PATCH. + */ +PROTOBUF_C_API +uint32_t +protobuf_c_version_number(void); + +/** + * The version of the protobuf-c headers, represented as a string using the same + * format as protobuf_c_version(). + */ +#define PROTOBUF_C_VERSION "1.0.0-pre" + +/** + * The version of the protobuf-c headers, represented as an integer using the + * same format as protobuf_c_version_number(). + */ +#define PROTOBUF_C_VERSION_NUMBER 1000000 + typedef int protobuf_c_boolean; typedef enum {