mirror of
https://github.com/protobuf-c/protobuf-c.git
synced 2024-12-26 21:04:23 +08:00
protobuf-c.{c,h}: use static empty_string on WIN32
MSVC has issues importing protobuf_c_empty_string from the DLL and using it in initializers, resulting in errors like when linking against protobuf-c.dll: test-proto3.pb-c.c(13): error C2099: initializer is not a constant test-proto3.pb-c.c(19): error C2440: 'initializing': cannot convert from 'void *' to 'Foo__Person__PhoneType' Work around the issue by not exporting protobuf_c_empty string and defining it as static const char[] in the protobuf-c.h file itself. This change only applies to _WIN32 shared library builds.
This commit is contained in:
parent
d9f098e3ab
commit
18ede005af
@ -84,7 +84,9 @@
|
||||
# define PROTOBUF_C_UNPACK_ERROR(...)
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) || !defined(PROTOBUF_C_USE_SHARED_LIB)
|
||||
const char protobuf_c_empty_string[] = "";
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Internal `ProtobufCMessage` manipulation macro.
|
||||
|
@ -238,7 +238,11 @@ PROTOBUF_C__BEGIN_DECLS
|
||||
#define PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC 0x114315af
|
||||
|
||||
/* Empty string used for initializers */
|
||||
#if defined(_WIN32) && defined(PROTOBUF_C_USE_SHARED_LIB)
|
||||
static const char protobuf_c_empty_string[] = "";
|
||||
#else
|
||||
extern const char protobuf_c_empty_string[];
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \defgroup api Public API
|
||||
|
Loading…
x
Reference in New Issue
Block a user