[zeromq-dev] Add build-information to ZMQ headers

Patric Schmitz bzk0711 at aol.com
Tue Jan 14 01:21:18 CET 2014

Dear zeromq developers,

in our project using zeromq, we depend on the PGM features which we use
for multicast synchronisation in our cluster environment. I would like
to be able to compile-time test, when building against zeromq, wether
that specific build has PGM support enabled or not, in order to abort
or warn the user if he tries to use a 'wrongly' configured build.
However, having looked at the zmq headers, I see, as of now, no way of
doing so.

I have looked into autoconf to see how this could be done. A simple
option would be to introduce a new header like zmq_config.h which
contains a subset of the undef/defines which are present in
src/platform.hpp as generated by autoheader. Since appropriate macros
such as ZMQ_HAVE_OPENPGM are already defined, we would just have to add
e.g. include/zeromq_config.h as a second AC_CONFIG_HEADER and put
only the build options relevant to the user in there.

There are already 'build-specific' options contained in zmq.h,
specifically the ZMQ_VERSION_* macros. I would prefer not to introduce
a separate header, but have the build configuration defines in zmq.h as
well. However, simply having the undefs automatically replaced by
autoconfig is not possible within zmq.h, since an AC_CONFIG_HEADER
should not contain any defines and undefs will be commented if they
were not AC_DEFINE'd, which will mess up #undef ZMQ_EXPORT at the end
of zmq.h for example.

It is however possible to make zmq.h an AC_CONFIG_FILE and have the
value of an autoconf variable exported via AC_SUBST substituted in the
generated file. A patch implementing that option is attached. Please
feel free to adapt it as you see fit and hopefully include this kind of
feature macros in future zmq versions.

Best regards
Patric Schmitz <bzk0711 at aol.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: autoconf_feature_macros.patch
Type: text/x-diff
Size: 30651 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140114/771667b2/attachment.patch>

More information about the zeromq-dev mailing list