michaelrsweet / mxml

Tiny XML library.
https://www.msweet.org/mxml
Apache License 2.0
426 stars 157 forks source link

Splitting config.h.in in two files. #303

Closed carlo-bramini closed 11 months ago

carlo-bramini commented 11 months ago

I would like to suggest to split config.h.in in two files. The first file is used by autotools as template for the macros emitted at configure time, that can be something like that:

/*
 * Configuration file for Mini-XML, a small XML file parsing library.
 *
 * https://www.msweet.org/mxml
 *
 * Copyright © 2003-2020 by Michael R Sweet.
 *
 * Licensed under Apache License v2.0.  See the file "LICENSE" for more
 * information.
 */

/*
 * Version number...
 */
#define MXML_VERSION    ""

/*
 * Inline function support...
 */
#define inline

/*
 * Long long support...
 */
#undef HAVE_LONG_LONG_INT

/*
 * Do we have the *printf() functions?
 */
#undef HAVE_SNPRINTF
#undef HAVE_VASPRINTF
#undef HAVE_VSNPRINTF

/*
 * Do we have the strXXX() functions?
 */
#undef HAVE_STRDUP
#undef HAVE_STRLCAT
#undef HAVE_STRLCPY

/*
 * Do we have threading support?
 */
#undef HAVE_PTHREAD_H

and then there is another file, that we may call common.h for example, which includes the generated config.h file and it does all operations moved outside like doing #include, #ifdef and so on. This is a fix that I made when adding support for CMake in my package for CYGWIN, because the common file would be the same for both autotools and CMake. I could write my config.h.cmake by keeping the same content of current config.h.in, but splitting the template allows to have less duplicated code, which would simplify the maintenance if CMake support will be added in the future.

What do you think?

michaelrsweet commented 11 months ago

While I've had a few requests to support cmake, and there is another issue and a PR for this, I do not want to make any changes towards this at this time.