[Zlib-devel] [PATCH] One last proposal to eliminate .rc mismatches
William A. Rowe, Jr.
wrowe at rowe-clan.net
Thu May 4 01:28:44 EDT 2006
Andrei Polushin wrote:
> William A. Rowe, Jr. wrote:
>
>>-#define ZLIB_VERSION "1.2.3"
>>-#define ZLIB_VERNUM 0x1230
>>+#define ZLIB_VERNUM_MAJOR 1
>>+#define ZLIB_VERNUM_MINOR 2
>>+#define ZLIB_VERNUM_MAINT 3
>
> By the way, comparing patches, the version is composed of four parts,
> not three.
Thanks for pointing this out.
Reading the FAQ earlier the eve, that would be ZLIB_VERNUM_PATCH. It might
be worthwhile to conditionally define this to 0, such that anyone could
pass -DZLIB_VERNUM_PATCH=7 to their specific flavor.
Unfortunately, that decorates the compiled binary, not the distributed .h,
so the end user/developer would be ignorant of the build flavor. Turns out
it must be tweaked in the source, so the declaration's simple...
#define ZLIB_VERNUM_PATCH 0
> For example, the next version might be 1.2.3.1, thus the fourth number
> is significant.
Well, not if I understand the FAQ; redhat might bundler 1.2.3.2, but zlib
will release 1.2.4 (IIUC). Build 0 is reserved to zlib, later builds are
(typically) the patches of others(?)
> Also here
>>+#define ZLIB_VERSION ZLIB_STRINGIZE_TOK( ZLIB_VERNUM_MAJOR ) \
Well not trivial, if build is "0" the dot's ommitted. This gets messy since
you can't continue into or nest an #ifdef into a macro expansion. (Also not
certain if there was a "1.2" or it was "1.2.0".)
The best I came up with is
#if ZLIB_VERNUM_PATCH
#define ZLIB_VERSION ZLIB_STRINGIZE_TOK( ZLIB_VERNUM_MAJOR ) \
"." ZLIB_STRINGIZE_TOK( ZLIB_VERNUM_MINOR ) \
"." ZLIB_STRINGIZE_TOK( ZLIB_VERNUM_MAINT ) \
"." ZLIB_STRINGIZE_TOK( ZLIB_VERNUM_PATCH )
#else
#define ZLIB_VERSION ZLIB_STRINGIZE_TOK( ZLIB_VERNUM_MAJOR ) \
"." ZLIB_STRINGIZE_TOK( ZLIB_VERNUM_MINOR ) \
"." ZLIB_STRINGIZE_TOK( ZLIB_VERNUM_MAINT )
#endif
since the alternative is something like
#if ZLIB_VERNUM_PATCH
#define ZLIB_VERDOT_PATCH "."
#else
#define ZLIB_VERDOT_PATCH
#endif
#define ZLIB_VERSION ZLIB_STRINGIZE_TOK( ZLIB_VERNUM_MAJOR ) \
"." ZLIB_STRINGIZE_TOK( ZLIB_VERNUM_MINOR ) \
"." ZLIB_STRINGIZE_TOK( ZLIB_VERNUM_MAINT ) \
ZLIB_VERDOT_BUILD ZLIB_STRINGIZE_TOK( ZLIB_VERNUM_PATCH )
the same number of lines and no more readable than the first. Better
suggestion welcome. This following was more trivial;
#define ZLIB_VERNUM ( ZLIB_VERNUM_MAJOR << 12
| ZLIB_VERNUM_MINOR << 8
| ZLIB_VERNUM_MAINT << 4
| ZLIB_VERNUM_PATCH )
> and here
>
>>FILEVERSION ZLIB_VERNUM_MAJOR,ZLIB_VERNUM_MINOR,ZLIB_VERNUM_MAINT,0
>>PRODUCTVERSION ZLIB_VERNUM_MAJOR,ZLIB_VERNUM_MINOR,ZLIB_VERNUM_MAINT,0
s/0/ZLIB_VERNUM_BUILD/
Of course. If Mark wants to adopt, the rest of the bits are trivial, so I won't
sweat submitting yet another patch, and I'm sure the result will be formatted
as he precisely prefers anyways.
Bill
More information about the Zlib-devel
mailing list