Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7695703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:36:19+00:00 2026-05-31T21:36:19+00:00

I want a debug function-macro that works like this: int myVar = 5; PRINTVAR(myVar);

  • 0

I want a debug function-macro that works like this:

int myVar = 5;
PRINTVAR(myVar); // macro

// which expands to something like...
print("myVar: ");
println(myVar);

Basically, I want to use the identifier as a string literal as well as a variable.

I’m just getting a bit sick of repeating myself when I want to dump out a whole lot of variables to the stdout.

My silly attempt, which of course doesn’t work:

#define PRINT_VAR(x) Serial.print("x: "); Serial.println(x);

Is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:36:20+00:00Added an answer on May 31, 2026 at 9:36 pm

    The “stringizing operator” is designed for precisely this case:

    #define PRINT_VAR(x) (print(#x ": "), println(x))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use Debug.Trace.trace to print something which I know is a Show
When debugging a function I usually use library(debug) mtrace(FunctionName) FunctionName(...) And that works quite
I have a ZF debug function like this: function fs_d($d, $at){ if($_REQUEST['debug']=='123'){ Zend_Debug::dump($d,'at: '
I want a debug function to do this, but I'm unaware of whether one
I have a mysql function, i want to debug it, set breakboints, see variables
I wanted to implement my own debug function that has the same signature as
in php i wrote my own debug function which have two arguments: text and
I want to debug a program I wrote. Therefor I'd like to link it
This is one thing I can't understand. I'm using a function which fetches records
I'm kinda stuck with this task. I have a macro that retrieve two ranges

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.