Skip to content

Commit 86304fd

Browse files
authored
chore: Create NoteDefines.h (#134)
Allows `#define`s to be shared across compilation units
1 parent be22b4c commit 86304fd

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

src/NoteDefines.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef NOTE_DEFINES_H
2+
#define NOTE_DEFINES_H
3+
4+
// Define the version of the `note-arduino` library
5+
#define NOTE_ARDUINO_VERSION_MAJOR 1
6+
#define NOTE_ARDUINO_VERSION_MINOR 6
7+
#define NOTE_ARDUINO_VERSION_PATCH 3
8+
9+
#define NOTE_ARDUINO_VERSION NOTE_C_STRINGIZE(NOTE_ARDUINO_VERSION_MAJOR) "." NOTE_C_STRINGIZE(NOTE_ARDUINO_VERSION_MINOR) "." NOTE_C_STRINGIZE(NOTE_ARDUINO_VERSION_PATCH)
10+
11+
// Unified attribute for marking functions as deprecated
12+
#if defined(__GNUC__) | defined(__clang__)
13+
#define NOTE_ARDUINO_DEPRECATED __attribute__((__deprecated__))
14+
#elif defined(_MSC_VER)
15+
#define NOTE_ARDUINO_DEPRECATED __declspec(deprecated)
16+
#else
17+
#define NOTE_ARDUINO_DEPRECATED
18+
#define NOTE_ARDUINO_NO_DEPRECATED_ATTR
19+
#endif // __GNUC__ || __clang__
20+
21+
#endif // NOTE_DEFINES_H

src/Notecard.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <stddef.h>
2828
#include <stdint.h>
2929

30+
#include "NoteDefines.h"
3031
#include "NoteI2c.hpp"
3132
#include "NoteLog.hpp"
3233
#include "NoteSerial.hpp"
@@ -45,21 +46,6 @@
4546
#include "mock/mock-parameters.hpp"
4647
#endif
4748

48-
#define NOTE_ARDUINO_VERSION_MAJOR 1
49-
#define NOTE_ARDUINO_VERSION_MINOR 6
50-
#define NOTE_ARDUINO_VERSION_PATCH 3
51-
52-
#define NOTE_ARDUINO_VERSION NOTE_C_STRINGIZE(NOTE_ARDUINO_VERSION_MAJOR) "." NOTE_C_STRINGIZE(NOTE_ARDUINO_VERSION_MINOR) "." NOTE_C_STRINGIZE(NOTE_ARDUINO_VERSION_PATCH)
53-
54-
#if defined(__GNUC__) | defined(__clang__)
55-
#define NOTE_ARDUINO_DEPRECATED __attribute__((__deprecated__))
56-
#elif defined(_MSC_VER)
57-
#define NOTE_ARDUINO_DEPRECATED __declspec(deprecated)
58-
#else
59-
#define NOTE_ARDUINO_DEPRECATED
60-
#define NOTE_ARDUINO_NO_DEPRECATED_ATTR
61-
#endif // __GNUC__ || __clang__
62-
6349
/**************************************************************************/
6450
/*!
6551
@brief Class that stores state and functions for interacting with the

0 commit comments

Comments
 (0)