Rigid Body Dynamics Library
rbdl_version.cc
Go to the documentation of this file.
1/*
2 * RBDL - Rigid Body Dynamics Library
3 * Copyright (c) 2011-2018 Martin Felis <martin@fysx.org>
4 *
5 * Licensed under the zlib license. See LICENSE for more details.
6 */
7
8#include <rbdl/rbdl_config.h>
9
10#include <iostream>
11#include <sstream>
12#include <string>
13#include <cstdlib>
14
15RBDL_DLLAPI int rbdl_get_api_version() {
16 static int compile_version = RBDL_API_VERSION;
17 return compile_version;
18}
19
20RBDL_DLLAPI void rbdl_check_api_version(int version) {
21 int compile_version = rbdl_get_api_version();
22
23 int compile_major = (compile_version & 0xff0000) >> 16;
24 int compile_minor = (compile_version & 0x00ff00) >> 8;
25 int compile_patch = (compile_version & 0x0000ff);
26
27 std::ostringstream compile_version_string("");
28 compile_version_string << compile_major << "." << compile_minor << "."
29 << compile_patch;
30
31 int version_major = (version & 0xff0000) >> 16;
32 int version_minor = (version & 0x00ff00) >> 8;
33 int version_patch = (version & 0x0000ff);
34
35 std::ostringstream link_version_string ("");
36 link_version_string << version_major << "." << version_minor << "."
37 << version_patch;
38
39 if (version_major != compile_major) {
40 std::cerr << "Error: trying to link against an incompatible RBDL library."
41 << std::endl;
42 std::cerr << "The library version is: " << compile_version_string.str()
43 << " but rbdl_config.h is version " << link_version_string.str()
44 << std::endl;
45 abort();
46 } else if (version_minor != compile_minor) {
47 std::cout << "Warning: RBDL library is of version "
48 << compile_version_string.str() << " but rbdl_config.h is from version "
49 << link_version_string.str() << std::endl;
50 }
51}
52
53RBDL_DLLAPI void rbdl_print_version() {
54 int compile_version = rbdl_get_api_version();
55
56 int compile_major = (compile_version & 0xff0000) >> 16;
57 int compile_minor = (compile_version & 0x00ff00) >> 8;
58 int compile_patch = (compile_version & 0x0000ff);
59
60 std::ostringstream compile_version_string("");
61 compile_version_string << compile_major << "." << compile_minor << "."
62 << compile_patch;
63
64 std::cout << "RBDL version:" << std::endl
65 << " API version : " << compile_version_string.str() << std::endl;
66
67 if (std::string("unknown") != RBDL_BUILD_COMMIT) {
68 std::cout << " commit : " << RBDL_BUILD_COMMIT
69 << " (branch: " << RBDL_BUILD_BRANCH << ")" << std::endl
70 << " build type : " << RBDL_BUILD_TYPE << std::endl;
71 }
72
73#ifdef RBDL_ENABLE_LOGGING
74 std::cout << " logging : on (warning: reduces performance!)" << std::endl;
75#else
76 std::cout << " logging : off" << std::endl;
77#endif
78
79#ifdef RBDL_BUILD_ADDON_LUAMODEL
80 std::cout << " LuaModel : on" << std::endl;
81#else
82 std::cout << " LuaModel : off" << std::endl;
83#endif
84
85#ifdef RBDL_BUILD_ADDON_URDFREADER
86 std::cout << " URDFReader : on" << std::endl;
87#else
88 std::cout << " URDFReader : off" << std::endl;
89#endif
90
91 std::string build_revision (RBDL_BUILD_COMMIT);
92 if (build_revision == "unknown") {
93 std::cout << std::endl
94 << "Version information incomplete: to enable version information re-build"
95 << std::endl
96 << "library from valid repository and enable RBDL_STORE_VERSION."
97 << std::endl;
98 }
99}
RBDL_DLLAPI void rbdl_check_api_version(int version)
Definition: rbdl_version.cc:20
RBDL_DLLAPI int rbdl_get_api_version()
Definition: rbdl_version.cc:15
RBDL_DLLAPI void rbdl_print_version()
Definition: rbdl_version.cc:53