Memory usage: #define vs. static const for uint8_tLockup while evaluating Wire.requestFrom function...
Can the "Friends" spell be used without making the target hostile?
Why did Luke use his left hand to shoot?
A starship is travelling at 0.9c and collides with a small rock. Will it leave a clean hole through, or will more happen?
What is a good reason for every spaceship to carry a weapon on board?
What senses are available to a corpse subjected to a Speak with Dead spell?
Memory usage: #define vs. static const for uint8_t
Square Root Distance from Integers
Which RAF squadrons and aircraft types took part in the bombing of Berlin on the 25th of August 1940?
Are the positive and negative planes inner or outer planes in the Great Wheel cosmology model?
After checking in online, how do I know whether I need to go show my passport at airport check-in?
Do authors have to be politically correct in article-writing?
A fantasy book with seven white haired women on the cover
Does it take energy to move something in a circle?
Translation needed for 130 years old church document
What game did these black and yellow dice come from?
What does an unprocessed RAW file look like?
Not a Long-Winded Riddle
Does Skippy chunky peanut butter contain trans fat?
Am I correct in stating that the study of topology is purely theoretical?
How do you get out of your own psychology to write characters?
"Starve to death" Vs. "Starve to the point of death"
How do I prevent a homebrew Grappling Hook feature from trivializing Tomb of Annihilation?
Cat is tipping over bed-side lamps during the night
Why avoid shared user accounts?
Memory usage: #define vs. static const for uint8_t
Lockup while evaluating Wire.requestFrom function (Arduino)Malloc with Objects in Arduino librariesHID-Project problems with keycode enums'Non-Deterministic' memory usage on ArduinoQuestion of proper usage for F MacroDetailed analyse of memory usageWhat are safe memory usage limits?Is it possible to configure FRAM memory for use as stack and heap?Reducing Memory Usage lots of Floatsmemory usage “dos and don'ts”
I'm writing an Arduino library to communicate with an I2C device, and I'm wondering what the best way is to declare all the register addresses so as to save memory.
Using #defines
:
#define REGISTER_MOTOR_1_MODE 0x44
#define REGISTER_MOTOR_2_MODE 0x47
Or using static const
:
static const uint8_t REGISTER_MOTOR_1_MODE = 0x44;
static const uint8_t REGISTER_MOTOR_2_MODE = 0x47;
(Obviously I have more than just two registers I need to declare, but I thought two would illustrate the point just fine)
c++ memory-usage
add a comment |
I'm writing an Arduino library to communicate with an I2C device, and I'm wondering what the best way is to declare all the register addresses so as to save memory.
Using #defines
:
#define REGISTER_MOTOR_1_MODE 0x44
#define REGISTER_MOTOR_2_MODE 0x47
Or using static const
:
static const uint8_t REGISTER_MOTOR_1_MODE = 0x44;
static const uint8_t REGISTER_MOTOR_2_MODE = 0x47;
(Obviously I have more than just two registers I need to declare, but I thought two would illustrate the point just fine)
c++ memory-usage
define's are just "find and replace"s, and can bit you, if you do anything other than numbers. For example#define LED_MASK 0x01<<2
. A safe(r) way to write that would be#define LED_MASK (0x01<<2)
. See also stackoverflow.com/questions/6542270/…
– Gerben
18 hours ago
add a comment |
I'm writing an Arduino library to communicate with an I2C device, and I'm wondering what the best way is to declare all the register addresses so as to save memory.
Using #defines
:
#define REGISTER_MOTOR_1_MODE 0x44
#define REGISTER_MOTOR_2_MODE 0x47
Or using static const
:
static const uint8_t REGISTER_MOTOR_1_MODE = 0x44;
static const uint8_t REGISTER_MOTOR_2_MODE = 0x47;
(Obviously I have more than just two registers I need to declare, but I thought two would illustrate the point just fine)
c++ memory-usage
I'm writing an Arduino library to communicate with an I2C device, and I'm wondering what the best way is to declare all the register addresses so as to save memory.
Using #defines
:
#define REGISTER_MOTOR_1_MODE 0x44
#define REGISTER_MOTOR_2_MODE 0x47
Or using static const
:
static const uint8_t REGISTER_MOTOR_1_MODE = 0x44;
static const uint8_t REGISTER_MOTOR_2_MODE = 0x47;
(Obviously I have more than just two registers I need to declare, but I thought two would illustrate the point just fine)
c++ memory-usage
c++ memory-usage
asked 19 hours ago
Android DevAndroid Dev
1184
1184
define's are just "find and replace"s, and can bit you, if you do anything other than numbers. For example#define LED_MASK 0x01<<2
. A safe(r) way to write that would be#define LED_MASK (0x01<<2)
. See also stackoverflow.com/questions/6542270/…
– Gerben
18 hours ago
add a comment |
define's are just "find and replace"s, and can bit you, if you do anything other than numbers. For example#define LED_MASK 0x01<<2
. A safe(r) way to write that would be#define LED_MASK (0x01<<2)
. See also stackoverflow.com/questions/6542270/…
– Gerben
18 hours ago
define's are just "find and replace"s, and can bit you, if you do anything other than numbers. For example
#define LED_MASK 0x01<<2
. A safe(r) way to write that would be #define LED_MASK (0x01<<2)
. See also stackoverflow.com/questions/6542270/…– Gerben
18 hours ago
define's are just "find and replace"s, and can bit you, if you do anything other than numbers. For example
#define LED_MASK 0x01<<2
. A safe(r) way to write that would be #define LED_MASK (0x01<<2)
. See also stackoverflow.com/questions/6542270/…– Gerben
18 hours ago
add a comment |
3 Answers
3
active
oldest
votes
You'll find no noticeable difference memory-wise between the two.
The only real difference is that the const
method also imposes a type to the value, which can be useful for function overloading or mathematical operations.
Macros also have types.#define REGISTER_MOTOR_1_MODE 0x44
would causeREGISTER_MOTOR_1_MODE
to have a type ofint
. The difference is more in the explicitness of the type.
– Pharap
4 hours ago
@Pharap Almost... Macros do not have a type. However, the content of the macro can have either an implicit or explicit type. That type is nothing to do with the macro.
– Majenko♦
14 mins ago
add a comment |
A #define
is a preprocessor macro. As Gerben says in his comment, it's just an automated find-and-replace.
If you use it to hold things like C string constants, e.g. #define ERROR_STRING "You messed up, bud!"
it could actually cause your program to take more memory, since that same string literal will be duplicated every time you reference it. In that case a static const would be both type-safe AND reduce memory usage.
Would it be duplicated? I mean, isn't it the job of the compiler to ensure "You messed up, bud!" occurs exactly once in the string constant table?
– juhist
15 hours ago
2
@juhist: C++ explicitly states that the compiler can choose to duplicate identical strings, or not. Most compilers have a flag to either do this, or not. I think, by default, most compilers do not merge strings, in case the app relies on them being unique.
– Mooing Duck
14 hours ago
@MooingDuck I compiled a program having many std::printf("%pn", "foo"); lines in it. All of them print the same address.
– juhist
13 hours ago
@MooingDuck: While few compilers will guarantee that strings will always be merged, I think the normal reason is that upholding such a guarantee may impose extra build-time costs and complexity, and the savings in storage from merging strings may or may not be worthwhile.
– supercat
13 hours ago
1
@juhist: Sure. In your compiler and your compiler flags. With my compiler and my flags, I get different addresses.
– Mooing Duck
12 hours ago
|
show 2 more comments
Theoretically both approaches should consume the same amount of space and will probably result in the same code.
However, rather than that meaning "pick any one", what that actually means is that you should turn your attention to other factors when deciding which one to use.
As a rule of thumb you should generally avoid macros because they don't respect scoping rules due to how they work.
This can lead to some serious problems in certain cases.
See Why are preprocessor macros evil and what are the alternatives?.
However, I'd like to point out a third option: constexpr
.
constexpr uint8_t motorMode1Register = 0x44;
constexpr
implies const
and is a better expression of the intent that the value should be capable of being evaluated at compile time.constexpr
literally means "this is a constant expression and thus can be evaluated at compile time".
As a result of this, constexpr
variables can be used in situations where other variables cannot, such as template parameters.
See Constexpr vs Macros.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("schematics", function () {
StackExchange.schematics.init();
});
}, "cicuitlab");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "540"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2farduino.stackexchange.com%2fquestions%2f61970%2fmemory-usage-define-vs-static-const-for-uint8-t%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You'll find no noticeable difference memory-wise between the two.
The only real difference is that the const
method also imposes a type to the value, which can be useful for function overloading or mathematical operations.
Macros also have types.#define REGISTER_MOTOR_1_MODE 0x44
would causeREGISTER_MOTOR_1_MODE
to have a type ofint
. The difference is more in the explicitness of the type.
– Pharap
4 hours ago
@Pharap Almost... Macros do not have a type. However, the content of the macro can have either an implicit or explicit type. That type is nothing to do with the macro.
– Majenko♦
14 mins ago
add a comment |
You'll find no noticeable difference memory-wise between the two.
The only real difference is that the const
method also imposes a type to the value, which can be useful for function overloading or mathematical operations.
Macros also have types.#define REGISTER_MOTOR_1_MODE 0x44
would causeREGISTER_MOTOR_1_MODE
to have a type ofint
. The difference is more in the explicitness of the type.
– Pharap
4 hours ago
@Pharap Almost... Macros do not have a type. However, the content of the macro can have either an implicit or explicit type. That type is nothing to do with the macro.
– Majenko♦
14 mins ago
add a comment |
You'll find no noticeable difference memory-wise between the two.
The only real difference is that the const
method also imposes a type to the value, which can be useful for function overloading or mathematical operations.
You'll find no noticeable difference memory-wise between the two.
The only real difference is that the const
method also imposes a type to the value, which can be useful for function overloading or mathematical operations.
answered 19 hours ago
Majenko♦Majenko
68.2k43277
68.2k43277
Macros also have types.#define REGISTER_MOTOR_1_MODE 0x44
would causeREGISTER_MOTOR_1_MODE
to have a type ofint
. The difference is more in the explicitness of the type.
– Pharap
4 hours ago
@Pharap Almost... Macros do not have a type. However, the content of the macro can have either an implicit or explicit type. That type is nothing to do with the macro.
– Majenko♦
14 mins ago
add a comment |
Macros also have types.#define REGISTER_MOTOR_1_MODE 0x44
would causeREGISTER_MOTOR_1_MODE
to have a type ofint
. The difference is more in the explicitness of the type.
– Pharap
4 hours ago
@Pharap Almost... Macros do not have a type. However, the content of the macro can have either an implicit or explicit type. That type is nothing to do with the macro.
– Majenko♦
14 mins ago
Macros also have types.
#define REGISTER_MOTOR_1_MODE 0x44
would cause REGISTER_MOTOR_1_MODE
to have a type of int
. The difference is more in the explicitness of the type.– Pharap
4 hours ago
Macros also have types.
#define REGISTER_MOTOR_1_MODE 0x44
would cause REGISTER_MOTOR_1_MODE
to have a type of int
. The difference is more in the explicitness of the type.– Pharap
4 hours ago
@Pharap Almost... Macros do not have a type. However, the content of the macro can have either an implicit or explicit type. That type is nothing to do with the macro.
– Majenko♦
14 mins ago
@Pharap Almost... Macros do not have a type. However, the content of the macro can have either an implicit or explicit type. That type is nothing to do with the macro.
– Majenko♦
14 mins ago
add a comment |
A #define
is a preprocessor macro. As Gerben says in his comment, it's just an automated find-and-replace.
If you use it to hold things like C string constants, e.g. #define ERROR_STRING "You messed up, bud!"
it could actually cause your program to take more memory, since that same string literal will be duplicated every time you reference it. In that case a static const would be both type-safe AND reduce memory usage.
Would it be duplicated? I mean, isn't it the job of the compiler to ensure "You messed up, bud!" occurs exactly once in the string constant table?
– juhist
15 hours ago
2
@juhist: C++ explicitly states that the compiler can choose to duplicate identical strings, or not. Most compilers have a flag to either do this, or not. I think, by default, most compilers do not merge strings, in case the app relies on them being unique.
– Mooing Duck
14 hours ago
@MooingDuck I compiled a program having many std::printf("%pn", "foo"); lines in it. All of them print the same address.
– juhist
13 hours ago
@MooingDuck: While few compilers will guarantee that strings will always be merged, I think the normal reason is that upholding such a guarantee may impose extra build-time costs and complexity, and the savings in storage from merging strings may or may not be worthwhile.
– supercat
13 hours ago
1
@juhist: Sure. In your compiler and your compiler flags. With my compiler and my flags, I get different addresses.
– Mooing Duck
12 hours ago
|
show 2 more comments
A #define
is a preprocessor macro. As Gerben says in his comment, it's just an automated find-and-replace.
If you use it to hold things like C string constants, e.g. #define ERROR_STRING "You messed up, bud!"
it could actually cause your program to take more memory, since that same string literal will be duplicated every time you reference it. In that case a static const would be both type-safe AND reduce memory usage.
Would it be duplicated? I mean, isn't it the job of the compiler to ensure "You messed up, bud!" occurs exactly once in the string constant table?
– juhist
15 hours ago
2
@juhist: C++ explicitly states that the compiler can choose to duplicate identical strings, or not. Most compilers have a flag to either do this, or not. I think, by default, most compilers do not merge strings, in case the app relies on them being unique.
– Mooing Duck
14 hours ago
@MooingDuck I compiled a program having many std::printf("%pn", "foo"); lines in it. All of them print the same address.
– juhist
13 hours ago
@MooingDuck: While few compilers will guarantee that strings will always be merged, I think the normal reason is that upholding such a guarantee may impose extra build-time costs and complexity, and the savings in storage from merging strings may or may not be worthwhile.
– supercat
13 hours ago
1
@juhist: Sure. In your compiler and your compiler flags. With my compiler and my flags, I get different addresses.
– Mooing Duck
12 hours ago
|
show 2 more comments
A #define
is a preprocessor macro. As Gerben says in his comment, it's just an automated find-and-replace.
If you use it to hold things like C string constants, e.g. #define ERROR_STRING "You messed up, bud!"
it could actually cause your program to take more memory, since that same string literal will be duplicated every time you reference it. In that case a static const would be both type-safe AND reduce memory usage.
A #define
is a preprocessor macro. As Gerben says in his comment, it's just an automated find-and-replace.
If you use it to hold things like C string constants, e.g. #define ERROR_STRING "You messed up, bud!"
it could actually cause your program to take more memory, since that same string literal will be duplicated every time you reference it. In that case a static const would be both type-safe AND reduce memory usage.
answered 17 hours ago
Duncan CDuncan C
1,7291617
1,7291617
Would it be duplicated? I mean, isn't it the job of the compiler to ensure "You messed up, bud!" occurs exactly once in the string constant table?
– juhist
15 hours ago
2
@juhist: C++ explicitly states that the compiler can choose to duplicate identical strings, or not. Most compilers have a flag to either do this, or not. I think, by default, most compilers do not merge strings, in case the app relies on them being unique.
– Mooing Duck
14 hours ago
@MooingDuck I compiled a program having many std::printf("%pn", "foo"); lines in it. All of them print the same address.
– juhist
13 hours ago
@MooingDuck: While few compilers will guarantee that strings will always be merged, I think the normal reason is that upholding such a guarantee may impose extra build-time costs and complexity, and the savings in storage from merging strings may or may not be worthwhile.
– supercat
13 hours ago
1
@juhist: Sure. In your compiler and your compiler flags. With my compiler and my flags, I get different addresses.
– Mooing Duck
12 hours ago
|
show 2 more comments
Would it be duplicated? I mean, isn't it the job of the compiler to ensure "You messed up, bud!" occurs exactly once in the string constant table?
– juhist
15 hours ago
2
@juhist: C++ explicitly states that the compiler can choose to duplicate identical strings, or not. Most compilers have a flag to either do this, or not. I think, by default, most compilers do not merge strings, in case the app relies on them being unique.
– Mooing Duck
14 hours ago
@MooingDuck I compiled a program having many std::printf("%pn", "foo"); lines in it. All of them print the same address.
– juhist
13 hours ago
@MooingDuck: While few compilers will guarantee that strings will always be merged, I think the normal reason is that upholding such a guarantee may impose extra build-time costs and complexity, and the savings in storage from merging strings may or may not be worthwhile.
– supercat
13 hours ago
1
@juhist: Sure. In your compiler and your compiler flags. With my compiler and my flags, I get different addresses.
– Mooing Duck
12 hours ago
Would it be duplicated? I mean, isn't it the job of the compiler to ensure "You messed up, bud!" occurs exactly once in the string constant table?
– juhist
15 hours ago
Would it be duplicated? I mean, isn't it the job of the compiler to ensure "You messed up, bud!" occurs exactly once in the string constant table?
– juhist
15 hours ago
2
2
@juhist: C++ explicitly states that the compiler can choose to duplicate identical strings, or not. Most compilers have a flag to either do this, or not. I think, by default, most compilers do not merge strings, in case the app relies on them being unique.
– Mooing Duck
14 hours ago
@juhist: C++ explicitly states that the compiler can choose to duplicate identical strings, or not. Most compilers have a flag to either do this, or not. I think, by default, most compilers do not merge strings, in case the app relies on them being unique.
– Mooing Duck
14 hours ago
@MooingDuck I compiled a program having many std::printf("%pn", "foo"); lines in it. All of them print the same address.
– juhist
13 hours ago
@MooingDuck I compiled a program having many std::printf("%pn", "foo"); lines in it. All of them print the same address.
– juhist
13 hours ago
@MooingDuck: While few compilers will guarantee that strings will always be merged, I think the normal reason is that upholding such a guarantee may impose extra build-time costs and complexity, and the savings in storage from merging strings may or may not be worthwhile.
– supercat
13 hours ago
@MooingDuck: While few compilers will guarantee that strings will always be merged, I think the normal reason is that upholding such a guarantee may impose extra build-time costs and complexity, and the savings in storage from merging strings may or may not be worthwhile.
– supercat
13 hours ago
1
1
@juhist: Sure. In your compiler and your compiler flags. With my compiler and my flags, I get different addresses.
– Mooing Duck
12 hours ago
@juhist: Sure. In your compiler and your compiler flags. With my compiler and my flags, I get different addresses.
– Mooing Duck
12 hours ago
|
show 2 more comments
Theoretically both approaches should consume the same amount of space and will probably result in the same code.
However, rather than that meaning "pick any one", what that actually means is that you should turn your attention to other factors when deciding which one to use.
As a rule of thumb you should generally avoid macros because they don't respect scoping rules due to how they work.
This can lead to some serious problems in certain cases.
See Why are preprocessor macros evil and what are the alternatives?.
However, I'd like to point out a third option: constexpr
.
constexpr uint8_t motorMode1Register = 0x44;
constexpr
implies const
and is a better expression of the intent that the value should be capable of being evaluated at compile time.constexpr
literally means "this is a constant expression and thus can be evaluated at compile time".
As a result of this, constexpr
variables can be used in situations where other variables cannot, such as template parameters.
See Constexpr vs Macros.
add a comment |
Theoretically both approaches should consume the same amount of space and will probably result in the same code.
However, rather than that meaning "pick any one", what that actually means is that you should turn your attention to other factors when deciding which one to use.
As a rule of thumb you should generally avoid macros because they don't respect scoping rules due to how they work.
This can lead to some serious problems in certain cases.
See Why are preprocessor macros evil and what are the alternatives?.
However, I'd like to point out a third option: constexpr
.
constexpr uint8_t motorMode1Register = 0x44;
constexpr
implies const
and is a better expression of the intent that the value should be capable of being evaluated at compile time.constexpr
literally means "this is a constant expression and thus can be evaluated at compile time".
As a result of this, constexpr
variables can be used in situations where other variables cannot, such as template parameters.
See Constexpr vs Macros.
add a comment |
Theoretically both approaches should consume the same amount of space and will probably result in the same code.
However, rather than that meaning "pick any one", what that actually means is that you should turn your attention to other factors when deciding which one to use.
As a rule of thumb you should generally avoid macros because they don't respect scoping rules due to how they work.
This can lead to some serious problems in certain cases.
See Why are preprocessor macros evil and what are the alternatives?.
However, I'd like to point out a third option: constexpr
.
constexpr uint8_t motorMode1Register = 0x44;
constexpr
implies const
and is a better expression of the intent that the value should be capable of being evaluated at compile time.constexpr
literally means "this is a constant expression and thus can be evaluated at compile time".
As a result of this, constexpr
variables can be used in situations where other variables cannot, such as template parameters.
See Constexpr vs Macros.
Theoretically both approaches should consume the same amount of space and will probably result in the same code.
However, rather than that meaning "pick any one", what that actually means is that you should turn your attention to other factors when deciding which one to use.
As a rule of thumb you should generally avoid macros because they don't respect scoping rules due to how they work.
This can lead to some serious problems in certain cases.
See Why are preprocessor macros evil and what are the alternatives?.
However, I'd like to point out a third option: constexpr
.
constexpr uint8_t motorMode1Register = 0x44;
constexpr
implies const
and is a better expression of the intent that the value should be capable of being evaluated at compile time.constexpr
literally means "this is a constant expression and thus can be evaluated at compile time".
As a result of this, constexpr
variables can be used in situations where other variables cannot, such as template parameters.
See Constexpr vs Macros.
answered 4 hours ago
PharapPharap
1498
1498
add a comment |
add a comment |
Thanks for contributing an answer to Arduino Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2farduino.stackexchange.com%2fquestions%2f61970%2fmemory-usage-define-vs-static-const-for-uint8-t%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
define's are just "find and replace"s, and can bit you, if you do anything other than numbers. For example
#define LED_MASK 0x01<<2
. A safe(r) way to write that would be#define LED_MASK (0x01<<2)
. See also stackoverflow.com/questions/6542270/…– Gerben
18 hours ago