473,387 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

String macro as wchar_t pointer?

Hi!

#define TEST "this is a test"
const char * test = TEST;
const wchar_t * wtest = ???;

What must I write, to get TEST evaluated to L"this is a test" at compile
time?
Heiner
h.********@nospam.gmx.de
Remove the nospam to get my real address
Jun 23 '06 #1
2 2461


Heiner wrote On 06/23/06 17:15,:
Hi!

#define TEST "this is a test"
const char * test = TEST;
const wchar_t * wtest = ???;

What must I write, to get TEST evaluated to L"this is a test" at compile
time?


const wchar_t * wtest = L"" TEST;

.... taking advantage of string literal concatenation:
When a wide-string literal L"" is concatenated with a
char-string literal, the result is wide.

--
Er*********@sun.com

Jun 23 '06 #2
On Fri, 23 Jun 2006 18:18:50 -0400, Eric Sosman wrote:
const wchar_t * wtest = L"" TEST;

... taking advantage of string literal concatenation:
When a wide-string literal L"" is concatenated with a
char-string literal, the result is wide.


That's it. Thank you very much!

Heiner
Jun 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bren | last post by:
Hi all, I wonder if anyone knows of a string class out there that can do on demand conversion from wchar_t to char? We are writing an app that will need to be localized and cross platform. ...
18
by: Zygmunt Krynicki | last post by:
Hello I've browsed the FAQ but apparently it lacks any questions concenring wide character strings. I'd like to calculate the length of a multibyte string without converting the whole string. ...
6
by: Derrick Coetzee | last post by:
Looking through the C90 standard, it occurred to me that the possible syntaxes for initializers, particularly of wchar_t arrays, are really bizarre. Consider the following: wchar_t s1 = {...
8
by: Duncan Winn | last post by:
I am new to VC++7. I am using a method GetPrivateProfileString that requires an LPTSTR. I have defined this as a: char * data_name; I am then trying to convert this to an LPOLESTR and I...
13
by: Joe Thompson | last post by:
Hi, I am using VS 2003 writing a managed C++ windows app. I am calling PlaySound. The first parameter is a LPCSTR. I have a String *str representing a filename. I like using the String class...
2
by: John E Katich | last post by:
How can I cast a String to a const wchar_t*? Ths following code genreates a compile error: error C2664: '_wsplitpath' : cannot convert parameter 1 from 'System::String __gc *' to 'const...
4
by: diDE | last post by:
I want to convert a managed string array f.e. array<string^>^ Texts; // Elements 0: "ABC", 1: "HJO" to a TCHAR** or wchar_t** any ideas?
14
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
I have seen the following function to convert from a System::String^ to a const wchar_t*. I would like to get a LPCTSTR and AFAIK LPCTSTR is equal to const wchar_t*. Then it should all work right?...
2
by: LinLMa | last post by:
Hello everyone, I find strange result in the following program. 1. For string array, dereferencing it will result in the string itself, but for int array, dereferencing it will result in the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.