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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:42:26+00:00 2026-05-23T17:42:26+00:00

I have a Unicode Win32 application that uses 3rd party libraries, some of which

  • 0

I have a Unicode Win32 application that uses 3rd party libraries, some of which provide constants for their version information as #defined (narrow) strings. For instance, libpng has the following:

#define PNG_LIBPNG_VER_STRING "1.5.4"
#define PNG_HEADER_VERSION_STRING \
 " libpng version 1.5.4 - July 7, 2011\n"

I’m appending the various statically linked libraries version information to my About Box for easy version tracking, and it seemed like it would be simple to convert this constant into a wide string.

My first attempt was TEXT(PNG_HEADER_VERSION_STRING), but that fails as

#define __TEXT(quote) L##quote

.. and LPNGHEADER_VERSION_STRING doesn’t exist of course.

So I tried several combinations of double wrapping macros, and all sorts of ## tricks to attempt to add the L prefix to a macro’ed constant, but wasn’t able to. Am I missing something simple? How would you handle:

#define VERSIONSTR "Test V1.2.3"
const char* ver= VERSIONSTR;
const wchar* wver = _T(VERSIONSTR); // fails, should be L"Test V1.2.3"
#define VERSIONSTRW _T(VERSIONSTR);  // fails also

programmatically, without simply adding a duplicate L”Test V1.2.3″ and having to keep it in sync with the 3rd party library.

I know I can just convert it at runtime if I’m building for Unicode, but I thought surely there was a quick way to re-define this constant.

—UPDATE—

I missed the plot by doing something really stupid with my include structure. Fixing that allowed the double define wrapper to function as it should. Stupid on my part.

  • 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-23T17:42:26+00:00Added an answer on May 23, 2026 at 5:42 pm

    The trick is to use two macros. When a macro is expanded, the arguments are macro-expanded before being substituted into the replacement list. So WIDEN(VERSIONSTR) becomes WIDEN2("Test V1.2.3").

    #define WIDEN(quote) WIDEN2(quote)
    #define WIDEN2(quote) L##quote
    
    #define VERSIONSTR "Test V1.2.3"
    #define VERSIONSTRW WIDEN(VERSIONSTR)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 3rd party application from which I need to copy texts and
I have a Win32 C++ Application which supports UNICODE. I have a problem where
I have some unicode text that I want to clean up using regular expressions.
We have a non-Unicode, C++ application, written with Visual Studio, that has been originally
I have some Python code that's receiving a string with bad unicode in it.
I have a C++ Win32 application that runs as a console app if run
We have in the process of upgrading our application to full Unicode comptibility as
I have xml where some of the element values are unicode characters. Is it
I have an ATL control that I want to be Unicode-aware. I added a
I have a win 32 application written in c++ which sets the low level

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.