473,408 Members | 2,087 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,408 software developers and data experts.

How to redefine a typedefined type?

For example if anywhere defined MyChar as
typedef char MyChar;

Now I want to redefine MyChar as wchar_t, how can I do this?

Jun 20 '07 #1
10 17820

On Jun 19, 10:25 pm, Amber <guxiaobo1...@gmail.comwrote:
For example if anywhere defined MyChar as
typedef char MyChar;

Now I want to redefine MyChar as wchar_t, how can I do this?

Redefine in what context? If its in a different scope, you can simply:

typedef wchar_t MyChar;

but I'm guessing you can't do that in your case (whatever it may be).
More info?

Chris
Jun 20 '07 #2
On Jun 20, 10:45 am, Chris Fairles <chris.fair...@gmail.comwrote:
On Jun 19, 10:25 pm, Amber <guxiaobo1...@gmail.comwrote:
For example if anywhere defined MyChar as
typedef char MyChar;
Now I want to redefine MyChar as wchar_t, how can I do this?

Redefine in what context? If its in a different scope, you can simply:

typedef wchar_t MyChar;

but I'm guessing you can't do that in your case (whatever it may be).
More info?

Chris
I include a .h file, which defines some class and use typedef, now I
want replace the typedef with a with my ower type.
Jun 20 '07 #3
On Jun 19, 10:23 pm, Amber <guxiaobo1...@gmail.comwrote:
On Jun 20, 10:45 am, Chris Fairles <chris.fair...@gmail.comwrote:
On Jun 19, 10:25 pm, Amber <guxiaobo1...@gmail.comwrote:
For example if anywhere defined MyChar as
typedef char MyChar;
Now I want to redefine MyChar as wchar_t, how can I do this?
Redefine in what context? If its in a different scope, you can simply:
typedef wchar_t MyChar;
but I'm guessing you can't do that in your case (whatever it may be).
More info?
Chris

I include a .h file, which defines some class and use typedef, now I
want replace the typedef with a with my ower type.
Unfortunately it's not possible.

Jun 20 '07 #4
On Jun 20, 11:25 am, Amber <guxiaobo1...@gmail.comwrote:
For example if anywhere defined MyChar as
typedef char MyChar;

Now I want to redefine MyChar as wchar_t, how can I do this?
I exactly can't predict on what context you need to behave like this.
typedef is a compile time operator.
In my assumption, you are trying to do a typdefinition according to
some other definitions. Like UNICODE..

In that context you can do as follwos

#ifdef UNICODE // or the symbol you need
typedef char MyChar;
#else
typedef wchar_t MyChar;
#endif

You only need to define or undefine symbol as per your requirement.

Regards,
Sarath
http://sarathc.wordpress.com/

Jun 20 '07 #5
Amber wrote:
For example if anywhere defined MyChar as
typedef char MyChar;

Now I want to redefine MyChar as wchar_t, how can I do this?
You can't redefine a typedef in the same scope.

--
Ian Collins.
Jun 20 '07 #6
I am using loki, in my case somebody defines XXXList as typelist with
some types,
and I am going to appand another type to the list, and then typedef
the new list as XXXList;

Jun 20 '07 #7
Amber wrote:
I am using loki, in my case somebody defines XXXList as typelist with
some types,
and I am going to appand another type to the list, and then typedef
the new list as XXXList;
Were you replying to me? Please retain enough context for your post to
make sense.

One solution would be to put your stuff in its own namespace.

--
Ian Collins.
Jun 20 '07 #8
On Jun 20, 2:55 am, Amber <guxiaobo1...@gmail.comwrote:
I am using loki, in my case somebody defines XXXList as typelist with
some types,
and I am going to appand another type to the list, and then typedef
the new list as XXXList;
You need to call it something else. By the time it reaches your new
typedef, a lot of code and files have already been compiled using the
old typedef. What would be your expected behavior? Would it change
the old code to use the new typelist, or would the old code get the
old value and any future code get the new value?

Jun 20 '07 #9
A crude way is to #define so the given typename actually means
something else (textually) in your code.
Use at your own risk....

Jun 20 '07 #10
OK, the actual thing I want is to make sure some strings constants are
unique at complie time, for example:

template<const char * text>
class Unit{
public:
const char * GetName(){return text;}
};
//--------------------------------
1.h
const char[] s1 = "Handler1";

typedef TYPELIST_1(Unit<s1>)) HandlerList;

//------------------------------------------
2.h
#include "1.h"

const char[] s2 = "Handler2";
typedef Appand<Unit<s2>, HandlerList>::Result HandlerList;

Jun 21 '07 #11

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

Similar topics

8
by: Steven Bethard | last post by:
I tried to Google for past discussion on this topic, but without much luck. If this has been discussed before, I'd be grateful for a pointer. Does anyone know why you can't assign a custom...
0
by: Michael Bane | last post by:
Am I right in thinking that... 1) in <redefine> I can either extend OR restrict a type but not both? 2) in <redefine> it's not possible to change a type from say <xs:string> to <xs:integer>? ...
2
by: BillD | last post by:
I'm trying to derive a schema from a base schema. I want to redefine a "group" from the base schema in my derived schema in order to add more options to the "choice" aggregate (see schema1.xsd...
1
by: Cat | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm getting a validation error when I try to restrict the content of nested groups with xs:redefine whereas the same restriction on xs:element's...
3
by: junlia | last post by:
We are using ACORD xml schema standard, and we need to add to it, so we choose to redefine ACORD xml schema. One of the problems that I ran into is how to add some values to an emumerated list. ...
2
by: bjhartin | last post by:
Hello all, I am having a problem with extending complex types. I have a simple base schema (FooBar.xsd) which defines XML documents of the following form: <Foo FooAttribute1="aaa"> <Bar...
0
by: bjhartin | last post by:
Hello, I'm struggling to extend the types defined in a schema. I've searched this group (and others) with no luck so far. I have the following two schemas: <!-- foobar.xsd --> <!-- A...
12
by: Just D | last post by:
All, It was possible before in Pascal, C++, etc. to define our custom data type or redefine the existing type, like in Turbo Pascal we could assume that shortint is int and use all references to...
1
by: Felix T. | last post by:
I have a class called Interval(type.ObjectType) that is supposed to mimic closed mathematical intervals. Right now, it has a lot of methods like this: def __add__(self,other): if type(other) in...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...
0
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...
0
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...

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.