Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API: introduce alternative, header-based versioning
Mainly as a light-weight alternative to full-blown autoconf/pkg-config machineries, whereby one can: * workaround functionality not present in libqb up to 1.0 (inclusive) - note that this versioning schema is being introduced *after* 1.0.0 release so one cannot tell that version from any older, but will be able to safely identify any later one (1.0.1+) and act accordingly - example: #if !defined(QB_VER_MAJOR) || ((QB_VER_MAJOR == 1) && (QB_VER_MINOR < 1)) #warning "Feature X not supported" int do_foo(int arg) { }; #else int do_foo(int arg) { /* use feature X of libqb */ } #endif * make its program report libqb API version it was built with by emitting QB_VER_STR symbolic string (see tests/print_ver.c for example) Also added is a print_ver test program to: * emit how original unparsed version is parsed to particular components defined in qbconfig.h (QB_VER_{MAJOR,MINOR,PATCH} symbolic integer constants and QB_VER_REST symbolic string) when being compiled * emit mentioned QB_VER_STR symbolic string joining the components back to a single string, plus the components themselves Resolves: #186
- Loading branch information
Showing
5 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ format_compare_speed | |
crash_test_dummy | ||
file_change_bytes | ||
test.conf | ||
print_ver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2016 Red Hat, Inc. | ||
* | ||
* All rights reserved. | ||
* | ||
* Author: Jan Pokorny <jpokorny@redhat.com> | ||
* | ||
* This file is part of libqb. | ||
* | ||
* libqb is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 2.1 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* libqb is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with libqb. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "os_base.h" /* instead of assert.h & stdio.h + defines VERSION */ | ||
|
||
#include <qb/qbconfig.h> /* QB_VER_{MAJOR,MINOR,PATCH,REST} + QB_VER_STR */ | ||
#include <qb/qbdefs.h> /* QB_PP_STRINGIFY */ | ||
|
||
int | ||
main(void) | ||
{ | ||
printf("%s consists of: %d, %d, %d, %s\n", QB_VER_STR, | ||
QB_VER_MAJOR, QB_VER_MINOR, QB_VER_PATCH, QB_VER_REST); | ||
return 0; | ||
} | ||
|
||
/* make version components emitted during "make check" for easy inspection; | ||
semicolon intentionally omitted so as to avoid unnecessary message | ||
source diagnostics (bug or feature?) with some GCC versions (5.3.1) */ | ||
#define MSG QB_PP_STRINGIFY( \ | ||
GCC warning QB_PP_STRINGIFY(VERSION parsed as: QB_VER_STR)) | ||
_Pragma(MSG) |