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?










share|improve this question









New contributor




MarkCalaway is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    remove the second parameter. you have DEC or HEX in macro name
    – Juraj
    2 days ago

















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?










share|improve this question









New contributor




MarkCalaway is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    remove the second parameter. you have DEC or HEX in macro name
    – Juraj
    2 days ago















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?










share|improve this question









New contributor




MarkCalaway is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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






share|improve this question









New contributor




MarkCalaway is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




MarkCalaway is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago









gre_gor

4,04192631




4,04192631






New contributor




MarkCalaway is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









MarkCalaway

62




62




New contributor




MarkCalaway is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





MarkCalaway is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






MarkCalaway is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1




    remove the second parameter. you have DEC or HEX in macro name
    – Juraj
    2 days ago
















  • 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














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);  





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    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',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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
    });


    }
    });






    MarkCalaway is a new contributor. Be nice, and check out our Code of Conduct.










     

    draft saved


    draft discarded


















    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

























    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);  





    share|improve this answer



























      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);  





      share|improve this answer

























        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);  





        share|improve this answer














        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);  






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 days ago

























        answered 2 days ago









        Mike

        1,6451421




        1,6451421






















            MarkCalaway is a new contributor. Be nice, and check out our Code of Conduct.










             

            draft saved


            draft discarded


















            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.















             


            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Wiesbaden

            Marschland

            Dieringhausen