473,847 Members | 1,452 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 8318
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
14956
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
1450
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
1610
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
2891
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
1148
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
4073
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
3367
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
2387
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
9734
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
10653
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...
1
10718
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5725
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
5915
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4129
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3168
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.