There is a RPC framework, using hessian as out default serialization. Then, some clients need protobuf. In order to be compatible with those people who do not have protobuf installed, we put all protobuf supports into a single file, and compile it conditionally according to the current enviroment(have pb or not)
The framework has a serial of data types(Long, String, Map, etc), each of them has a serializer seperately, we use a static struct to register these functions, it looks like:
/*file register.cc */
In the protobuf support file, we do the similar things:
/* pb_support.cc */
the two files exit in different directories:
In gcc 4.1.2 with Redhat5.6, it works well. In gcc 4.8 with Ubuntu 13.04, When protobuf is in, the pb_object_install always excutes first, but the result of is zero, that means the result of pb registeration has been wiped out, so protobuf protocol is useless.
Why is that? and is there any substitution to accomplish the same function?