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 7665119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:28:48+00:00 2026-05-31T14:28:48+00:00

I have a macro I use for debugging. #define diagnostic_arg(message,…) fprintf(stderr,message,__VA_ARGS__) I’ve found that

  • 0

I have a macro I use for debugging.

#define diagnostic_arg(message,...) fprintf(stderr,message,__VA_ARGS__)

I’ve found that I need to use wide-chars in my program, so I would like to change just my macro and have everything work:

#define diagnostic_arg(message,...) fwprintf(stderr,message,__VA_ARGS__)

However, I need wide character strings, which are defined by putting an L in front of the string’s beginning quote mark:

#define diagnostic_arg(message,...) fprintf(stderr,Lmessage,__VA_ARGS__)

Now obviously, the above line doesn’t work. But if I use L message, that won’t work either. So how do I write Lmessage and have it do what I would like?

  • 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-31T14:28:49+00:00Added an answer on May 31, 2026 at 2:28 pm

    You can use the token pasting operator ##:

    #define diagnostic_arg(message,...) fprintf(stderr,L##message,__VA_ARGS__)
    

    However, it might be better to use TEXT macro (if you are in Visual Studio) which will do the right thing whether UNICODE is defined or not:

    #define diagnostic_arg(message,...) fprintf(stderr,TEXT(message),__VA_ARGS__)
    

    If you’re not, TEXT can be defined like this:

    #ifdef UNICODE
    #define TEXT(str) L##str
    #else
    #define TEXT(str) str
    #endif
    

    However, if you plan on using other #defines as the first argument to this macro (and really even if you don’t plan on it), you will need another layer of indirection in the macro so the definition will be evaluated instead of pasted together with L as text. See Mooing Duck’s answer for how to do that, his is actually the correct way to do this, but I’m not deleting this answer because I want to keep my 80 rep.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In C/C++, I have often found it useful while debugging to define a macro,
I have a macro where I pass in an argument and use that define
I have a 'foreach' macro I use frequently in C++ that works for most
I have a macro that looks like this: #define coutError if (VERBOSITY_SETTING >= VERBOSITY_ERROR)
I have a macro that I use to replace special characters for its html
I have a macro in Notepad++ that I don't use any more, the macro
I have a macro that might look as follows (from boost log library) #define
i have a macro that i use to speed up the implementation of Factory
I have a very simple macro that I use for shorthand when declaring exceptions.
I have following macro in my PCH file. #ifdef DEBUG #define MYLOG(...) NSLog(__VA_ARGS__) #else

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.