Skip to content

Commit

Permalink
Use std::string in C++ versioning logic
Browse files Browse the repository at this point in the history
  • Loading branch information
daljit46 committed Oct 1, 2024
1 parent 6c50c05 commit 2c68665
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cpp/lib/core/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ void init(int cmdline_argc, const char *const *cmdline_argv) {
NAME.erase(NAME.size() - 4);
#endif

if (strcmp(mrtrix_version, executable_uses_mrtrix_version) != 0) {
if (mrtrix_version != executable_uses_mrtrix_version) {
Exception E("executable was compiled for a different version of the MRtrix3 library!");
E.push_back(std::string(" ") + NAME + " version: " + executable_uses_mrtrix_version);
E.push_back(std::string(" library version: ") + mrtrix_version);
Expand Down
4 changes: 2 additions & 2 deletions cpp/lib/core/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ extern void run();

namespace MR::App {

extern const char *mrtrix_version;
extern const char *build_date;
extern const std::string mrtrix_version;
extern const std::string build_date;
extern int log_level;
extern int exit_error_code;
extern std::string NAME;
Expand Down
2 changes: 1 addition & 1 deletion cpp/lib/core/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#endif

#include "app.h"
#include "cmd_version.h"
#include "executable_version.h"
#include "mrtrix.h"
#ifdef MRTRIX_PROJECT
namespace MR {
Expand Down
2 changes: 1 addition & 1 deletion cpp/lib/executable_version.cpp.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "cmd_version.h"
#include "executable_version.h"

namespace MR {
namespace App {
Expand Down
5 changes: 3 additions & 2 deletions cpp/lib/mrtrix_version.cpp.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "mrtrix_version.h"
#include <string>

namespace MR::App {
const char *mrtrix_version = "@MRTRIX_VERSION@";
const char *build_date = __DATE__;
const std::string mrtrix_version = "@MRTRIX_VERSION@";
const std::string build_date = __DATE__;
}
5 changes: 3 additions & 2 deletions cpp/lib/mrtrix_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
*/

#pragma once
#include <string>

namespace MR::App {
extern const char *mrtrix_version;
extern const char *build_date;
extern const std::string mrtrix_version;
extern const std::string build_date;
} // namespace MR::App

0 comments on commit 2c68665

Please sign in to comment.