473,583 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 17893

On Jun 19, 10:25 pm, Amber <guxiaobo1...@g mail.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...@g mail.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...@g mail.comwrote:
On Jun 20, 10:45 am, Chris Fairles <chris.fair...@ gmail.comwrote:
On Jun 19, 10:25 pm, Amber <guxiaobo1...@g mail.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...@g mail.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...@g mail.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

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

Similar topics

8
4696
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 mapping type to an object's __dict__? py> class M(object): .... def __getitem__(self, key): .... return 42 .... def...
0
1678
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>? 3) if I have schema1.xsd with <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
2
3345
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 sample). schema1.xsd sample: <!-- Here is a clipped down version of the group I want to redefine. --> <xsd:group name="INSURANCESVCRQMSGS">...
1
2210
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 validates. ============== BASE XMLSCHEMA ================= <?xml version="1.0"?> <xs:schema targetNamespace="test" xmlns="test"...
3
3597
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. For an emumerated list like this: <xsd:complexType name="AttachmentType"> <xsd:simpleContent> <xsd:restriction base="OpenEnum"> <xsd:enumeration...
2
1461
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 BarAttribute1="xxx"/> </Foo>
0
1290
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 'base' schema which will be 'extended' by customer specific ones --> <xs:schema ...>
12
13332
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 shortint like all these variables became int. How can we define our own user data type in C# is we can? Just D.
1
1977
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 Numerical: return Interval(self.lower_bound+other, self.upper_bound +other) else: return Interval(self.lower_bound+other.lower_bound,
0
7888
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...
0
7811
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...
0
8159
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7922
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...
0
6571
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...
1
5689
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...
0
5366
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...
1
2317
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
1
1416
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.