Macro arguments HEX and DEC
up vote
0
down vote
favorite
According to that guide: enter link description here
i wrote:
#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(x) Serial.print (x)
#define DEBUG_PRINTLN(x) Serial.println (x)
#define DEBUG_PRINT_HEX(x) Serial.print (x, HEX)
#define DEBUG_PRINT_DEC(x) Serial.print (x, DEC)
#else
#define DEBUG_PRINT(x)
#define DEBUG_PRINTLN(x)
#define DEBUG_PRINT_HEX(x)
#define DEBUG_PRINT_DEC(x)
#endif
if i call a function:
uint32_t versiondata;
DEBUG_PRINT_HEX((versiondata>>24) & 0xFF, HEX);
DEBUG_PRINT_DEC((versiondata>>16) & 0xFF, DEC);
uint8_t uidLength;
DEBUG_PRINT_DEC(uidLength, DEC);
the compiler give me:
error: macro "DEBUG_PRINT_DEC" passed 2 arguments, but takes just 1
error: macro "DEBUG_PRINT_HEX" passed 2 arguments, but takes just 1
Someone can explain me why does not works?
c++ arduino macros
New contributor
add a comment |
up vote
0
down vote
favorite
According to that guide: enter link description here
i wrote:
#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(x) Serial.print (x)
#define DEBUG_PRINTLN(x) Serial.println (x)
#define DEBUG_PRINT_HEX(x) Serial.print (x, HEX)
#define DEBUG_PRINT_DEC(x) Serial.print (x, DEC)
#else
#define DEBUG_PRINT(x)
#define DEBUG_PRINTLN(x)
#define DEBUG_PRINT_HEX(x)
#define DEBUG_PRINT_DEC(x)
#endif
if i call a function:
uint32_t versiondata;
DEBUG_PRINT_HEX((versiondata>>24) & 0xFF, HEX);
DEBUG_PRINT_DEC((versiondata>>16) & 0xFF, DEC);
uint8_t uidLength;
DEBUG_PRINT_DEC(uidLength, DEC);
the compiler give me:
error: macro "DEBUG_PRINT_DEC" passed 2 arguments, but takes just 1
error: macro "DEBUG_PRINT_HEX" passed 2 arguments, but takes just 1
Someone can explain me why does not works?
c++ arduino macros
New contributor
1
remove the second parameter. you have DEC or HEX in macro name
– Juraj
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
According to that guide: enter link description here
i wrote:
#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(x) Serial.print (x)
#define DEBUG_PRINTLN(x) Serial.println (x)
#define DEBUG_PRINT_HEX(x) Serial.print (x, HEX)
#define DEBUG_PRINT_DEC(x) Serial.print (x, DEC)
#else
#define DEBUG_PRINT(x)
#define DEBUG_PRINTLN(x)
#define DEBUG_PRINT_HEX(x)
#define DEBUG_PRINT_DEC(x)
#endif
if i call a function:
uint32_t versiondata;
DEBUG_PRINT_HEX((versiondata>>24) & 0xFF, HEX);
DEBUG_PRINT_DEC((versiondata>>16) & 0xFF, DEC);
uint8_t uidLength;
DEBUG_PRINT_DEC(uidLength, DEC);
the compiler give me:
error: macro "DEBUG_PRINT_DEC" passed 2 arguments, but takes just 1
error: macro "DEBUG_PRINT_HEX" passed 2 arguments, but takes just 1
Someone can explain me why does not works?
c++ arduino macros
New contributor
According to that guide: enter link description here
i wrote:
#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(x) Serial.print (x)
#define DEBUG_PRINTLN(x) Serial.println (x)
#define DEBUG_PRINT_HEX(x) Serial.print (x, HEX)
#define DEBUG_PRINT_DEC(x) Serial.print (x, DEC)
#else
#define DEBUG_PRINT(x)
#define DEBUG_PRINTLN(x)
#define DEBUG_PRINT_HEX(x)
#define DEBUG_PRINT_DEC(x)
#endif
if i call a function:
uint32_t versiondata;
DEBUG_PRINT_HEX((versiondata>>24) & 0xFF, HEX);
DEBUG_PRINT_DEC((versiondata>>16) & 0xFF, DEC);
uint8_t uidLength;
DEBUG_PRINT_DEC(uidLength, DEC);
the compiler give me:
error: macro "DEBUG_PRINT_DEC" passed 2 arguments, but takes just 1
error: macro "DEBUG_PRINT_HEX" passed 2 arguments, but takes just 1
Someone can explain me why does not works?
c++ arduino macros
c++ arduino macros
New contributor
New contributor
edited 2 days ago
gre_gor
4,04192631
4,04192631
New contributor
asked 2 days ago
MarkCalaway
62
62
New contributor
New contributor
1
remove the second parameter. you have DEC or HEX in macro name
– Juraj
2 days ago
add a comment |
1
remove the second parameter. you have DEC or HEX in macro name
– Juraj
2 days ago
1
1
remove the second parameter. you have DEC or HEX in macro name
– Juraj
2 days ago
remove the second parameter. you have DEC or HEX in macro name
– Juraj
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Look at the error message. You had defined this macro:
#define DEBUG_PRINT_HEX(x)
This macro want one argument: the x
And you call the macro with two arguments:
DEBUG_PRINT_HEX((versiondata>>24) & 0xFF, HEX);
1 argument: (versiondata>>24) & 0xFF
2 argument: HEX
Just call the macro like this:
DEBUG_PRINT_HEX((versiondata>>24) & 0xFF);
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Look at the error message. You had defined this macro:
#define DEBUG_PRINT_HEX(x)
This macro want one argument: the x
And you call the macro with two arguments:
DEBUG_PRINT_HEX((versiondata>>24) & 0xFF, HEX);
1 argument: (versiondata>>24) & 0xFF
2 argument: HEX
Just call the macro like this:
DEBUG_PRINT_HEX((versiondata>>24) & 0xFF);
add a comment |
up vote
0
down vote
accepted
Look at the error message. You had defined this macro:
#define DEBUG_PRINT_HEX(x)
This macro want one argument: the x
And you call the macro with two arguments:
DEBUG_PRINT_HEX((versiondata>>24) & 0xFF, HEX);
1 argument: (versiondata>>24) & 0xFF
2 argument: HEX
Just call the macro like this:
DEBUG_PRINT_HEX((versiondata>>24) & 0xFF);
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Look at the error message. You had defined this macro:
#define DEBUG_PRINT_HEX(x)
This macro want one argument: the x
And you call the macro with two arguments:
DEBUG_PRINT_HEX((versiondata>>24) & 0xFF, HEX);
1 argument: (versiondata>>24) & 0xFF
2 argument: HEX
Just call the macro like this:
DEBUG_PRINT_HEX((versiondata>>24) & 0xFF);
Look at the error message. You had defined this macro:
#define DEBUG_PRINT_HEX(x)
This macro want one argument: the x
And you call the macro with two arguments:
DEBUG_PRINT_HEX((versiondata>>24) & 0xFF, HEX);
1 argument: (versiondata>>24) & 0xFF
2 argument: HEX
Just call the macro like this:
DEBUG_PRINT_HEX((versiondata>>24) & 0xFF);
edited 2 days ago
answered 2 days ago
Mike
1,6451421
1,6451421
add a comment |
add a comment |
MarkCalaway is a new contributor. Be nice, and check out our Code of Conduct.
MarkCalaway is a new contributor. Be nice, and check out our Code of Conduct.
MarkCalaway is a new contributor. Be nice, and check out our Code of Conduct.
MarkCalaway is a new contributor. Be nice, and check out our Code of Conduct.
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%2fstackoverflow.com%2fquestions%2f53371222%2fmacro-arguments-hex-and-dec%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
1
remove the second parameter. you have DEC or HEX in macro name
– Juraj
2 days ago