Skip to content

Commit

Permalink
feat: バージョン情報を追加 #157 #188 (#266)
Browse files Browse the repository at this point in the history
* feat: バージョン情報を示すヘッダを追加 #157

* feat: spirit.h に version.h を追加 #157

* feat: エラー出力にバージョン情報を出力 #188

* feat: バージョン情報をマクロからコンパイル時定数に変更 #157

* docs: 各定数に説明を追加 #157
  • Loading branch information
yutotnh authored Aug 14, 2023
1 parent 5bf4808 commit 0460a08
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/spirit.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "spirit/include/bfloat16.h"
#include "spirit/include/bit.h"
#include "spirit/include/mutex.h"
#include "spirit/include/version.h"

#ifdef __MBED__
#include "spirit/platform/mbed/include/DigitalOut.h"
Expand Down
24 changes: 24 additions & 0 deletions src/spirit/include/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef SPIRIT_VERSION_H
#define SPIRIT_VERSION_H

namespace spirit {

namespace version {

/// バージョン番号のメジャー番号
constexpr uint32_t major = 0;

/// バージョン番号のマイナー番号
constexpr uint32_t minor = 1;

/// バージョン番号のパッチ番号
constexpr uint32_t patch = 0;

/// バージョン番号の文字列
constexpr char string[] = "0.1.0";

} // namespace version

} // namespace spirit

#endif // SPIRIT_VERSION_H
10 changes: 7 additions & 3 deletions src/spirit/src/Error.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "spirit/include/Error.h"

#include "cstdarg"
#include <cstdarg>

#include "spirit/include/version.h"

#ifdef __MBED__
#include "mbed.h"
Expand Down Expand Up @@ -94,16 +96,18 @@ void Error::print(Type type, uint32_t code, const char* filename, const char* fu
#ifdef __MBED__
printf(
#else
std::fprintf(stderr,
std::fprintf(
stderr,
#endif // __MBED__
"%s:\n"
"\tType: %s\n"
"\tError code: %d\n"
"\tVersion: %s\n"
"\tFile: %s\n"
"\tFunction: %s\n"
"\tLine: %d\n"
"\tMessage: ",
status_to_string(_status), type_to_string(type), code, filename, funcname, line_number);
status_to_string(_status), type_to_string(type), code, version::string, filename, funcname, line_number);

#ifdef __MBED__
vprintf(message, arg);
Expand Down

0 comments on commit 0460a08

Please sign in to comment.