473,809 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Replace _T() macros

Hi,

I would like to know if it would be possible to replace _T() macros used
on windows to delcare an ANSI string or a unicode one :

#ifdef UNICODE
#define __TEXT(quote) L##quote // r_winnt
#else
#define __TEXT(quote) ##quote
#endif

#define _T(x) __TEXT(x)

I was thinking of something like

_Text<char>("so me text") that would return "some text"
and
_Text<wchar_t>( "some text") that would return L"some text"

What is possible to do ?
Oct 29 '08 #1
2 8317
John Doe wrote:
Hi,

I would like to know if it would be possible to replace _T() macros used
on windows to delcare an ANSI string or a unicode one :

#ifdef UNICODE
#define __TEXT(quote) L##quote // r_winnt
#else
#define __TEXT(quote) ##quote
#endif

#define _T(x) __TEXT(x)

I was thinking of something like

_Text<char>("so me text") that would return "some text"
and
_Text<wchar_t>( "some text") that would return L"some text"

What is possible to do ?

First off, the name '_Text' is reserved by the implementation. Do *not*
under any circumstances name your variables/functions starting with an
underscore and a capital letter. That aside...

You cannot expect to define some mechanism that would somehow tweak your
source code and hope for it *not* to be a macro. That's the point. It
has to be a macro to squeeze the 'L' in front of the literal before the
compiler gets its hands on the code.

What is it you're trying to accomplish?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 29 '08 #2
On Oct 29, 5:25 pm, John Doe <mos...@anonymo us.orgwrote:
I would like to know if it would be possible to replace _T()
macros used on windows to delcare an ANSI string or a unicode
one :
#ifdef UNICODE
#define __TEXT(quote) L##quote // r_winnt
#else
#define __TEXT(quote) ##quote
#endif
#define _T(x) __TEXT(x)
I was thinking of something like
_Text<char>("so me text") that would return "some text"
and
_Text<wchar_t>( "some text") that would return L"some text"
The obvious first answer is that the above is impossible, since
the arguments to a macro have to be in the parentheses.

The obvious second answer is that it is trivial to write a small
preprocessor which does this; probably around a hundred lines of
code, in all (using flex and a simple state machine).

A less obvious third answer is that it doesn't buy you anything.
The way you process wide characters is different than what you
do with narrow characters; just changing char to wchar_t and
"..." to L"..." won't produce anything usable.

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Oct 30 '08 #3

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

Similar topics

3
5836
by: ree | last post by:
When I use the _T function in Dev-C++ if doesn't recognise the function. Is there a specifc header I need to include. Or is _T only useable in MFC? If so is there an equivalent for Dec-C++? TIA
2
14942
by: Daniel | last post by:
I use an Access database to basically take data exports, import them, manipulate the data, and then turn them into exportable reports. I do this using numerous macros, and queries to get the data in the format that I need it in order to create the reports that we use. So far this has proven to be successful for the reports that I am doing and the data that I am pulling into it. I just have one challenge that may require a lot of work and I...
0
1448
by: ianstratford | last post by:
I just released a new version of the free Microsoft Access find and replace add-in utility (version 1.5). Search and replace (optionally) any string in tables, queries, macros, forms, reports and modules in Access databases. The tool will now search and replace Report Group Levels (Thank you Judy). The new version also searches macros (logs results but does not
7
1607
by: Access2003Guru | last post by:
Instead of sending an entire form to a client that includes code changes, I'm trying to update just one section of code. If I know the object, function name & property, is there a way to search that function, and replace the current function's info with new function info? Example of what I need... (1) Open the "frmClients" form in design view. (I can do already). (2) Find the code behind the OnClick property of btnPrintHistory.
22
2886
by: Michael Nahas | last post by:
Antti & all interested, The draft description of my language to replace C is available at: http://nahas.is-a-geek.com/~mike/MyC.pdf I am a long time C programmer (I read the old testament in 1987) and I've tried to keep the spirit of C and make as few changes as possible. I was mostly driven by the bloat of C++ and, now, C99. I was also
2
1146
by: Just Me | last post by:
Using the IDE: Replace in Files Suppose I want to change all words: <something>Form to new words: Form<something> Can that be done and if so How? Thanks
2
4072
by: Chris Fairles | last post by:
I'm wondering if theres any rationale behind using _t vs _type in typedefs. I took a look in the standard and it doesn't say much besides things like "size_type must be size_t", "difference_type must be ptrdiff_t". Looking at some libraries in Boost (Boost.GIL specifically) the concepts describe types mainly using _type (value_type etc) but the odd _t sneaks in there (const_t, layout_t). One thing I notice is that _t is used more...
7
3364
by: Rohit | last post by:
Hi, I am working on a switch module which after reading voltage through a port pin and caterogizing it into three ranges(open,low or high), passes this range to a function switch_status() with parameters value and signal ID. Signal Id is used to get a user configurable parameter inside a configuration file, which depends on the type of switch. I have implemented it as under. Please ignore those magic numbers as I have mimized logic to...
2
2385
by: JP Romano | last post by:
Hello - have gotten some great advice from your site, so I figured I'd join and see how much more I can learn. Not a programmer, but am working on a project which requires me to do some VBA programming (via Excel 07). I'm currently trying to find a fast way to replace every blank (empty) cell in a range with a text string "No Data Available" My spreadsheet is over 28,000 rows, and the cells which need replacing are in columns D, E, F, and...
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7662
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.