473,671 Members | 2,298 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to undef a typedef??

Hi,
I did
typedef int Man;

After some code I get a necessity to use the same name Man for char. I
mean to say,I need to
typedef char Man;
But how can I do this???

Nov 16 '06 #1
15 29616
in************@ gmail.com wrote:
Hi,
I did
typedef int Man;

After some code I get a necessity to use the same name Man for char. I
mean to say,I need to
typedef char Man;
But how can I do this???
To a good first approximation [1], you can't.

Perhaps you could explain why you've painted yourself into this
corner? We can then discuss the alternatives to paint.

[1] No nested scopes.

--
Chris "hantwig efferko VOOM!" Dollin
"Never ask that question!" Ambassador Kosh, /Babylon 5/

Nov 16 '06 #2
in************@ gmail.com wrote:
Hi,
I did
typedef int Man;

After some code I get a necessity to use the same name Man for char. I
mean to say,I need to
typedef char Man;
But how can I do this???
Suggestion #1: Don't.

Suggestion #2: Put the two different `Man' uses in different
scopes. For example, use one typedef in function f() and the
other in function g(), and neither at file scope. Or use one at
file scope in source file a.c and the other in source file b.c,
compiled separately.

--
Eric Sosman
esosman@acm
Nov 16 '06 #3
in************@ gmail.com wrote:
Hi,
I did
typedef int Man;

After some code I get a necessity to use the same name Man for char. I
mean to say,I need to
typedef char Man;
But how can I do this???
You can't use

#undef <identifier>

because the specified <identifierha s to be a macro name, else the
undef will be ignored. However, this works:

#include <stdio.h>
#include <limits.h>

void typedef_func1(v oid)
{
typedef int Man;
Man i;

i = INT_MAX;

printf("INT_MAX : %d\n", i);
}

void typedef_func2(v oid)
{
typedef char Man;
Man c;

c = CHAR_MAX;

printf("CHAR_MA X: %d\n", (int)c);
}

int main(void)
{
typedef_func1() ;
typedef_func2() ;

return 0;
}

--
Tor <torust AT online DOT no>

Nov 16 '06 #4
in************@ gmail.com wrote:
>
Hi,
I did
typedef int Man;

After some code I get a necessity to use the same name Man for char. I
mean to say,I need to
typedef char Man;
But how can I do this???
As others have already said, "you can't" and "why would you want to?"

However, you can get close with something like:

typedef whatever Man_t1;
typedef something_else Man_t2;

#define Man Man_t1
...
#undef Man
#define Man Man_t2

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer .h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th***** ********@gmail. com>

Nov 16 '06 #5
"Kenneth Brody" writes:
>Hi,
I did
typedef int Man;

After some code I get a necessity to use the same name Man for char. I
mean to say,I need to
typedef char Man;
But how can I do this???

As others have already said, "you can't" and "why would you want to?"
Perhaps there is more than one programmer involved?
Nov 16 '06 #6
osmium wrote:
"Kenneth Brody" writes:
Please don't snip the attributions for things you are still quoting.
Kenneth definitely did *not* write the original question. I've
reinstated the attribution for the OPs question.
>>in*********** *@gmail.com wrote:
>>Hi,
I did
typedef int Man;

After some code I get a necessity to use the same name Man for char. I
mean to say,I need to
typedef char Man;
But how can I do this???
As others have already said, "you can't" and "why would you want to?"

Perhaps there is more than one programmer involved?
That would be an excellent reason to NOT do it. As others have
suggested, what the OP is trying to do is a very bad idea.
--
Flash Gordon
Nov 16 '06 #7
"Flash Gordon" <sp**@flash-gordon.me.ukwro te in message
news:h1******** ****@news.flash-gordon.me.uk...
osmium wrote:
>"Kenneth Brody" writes:

Please don't snip the attributions for things you are still quoting.
Kenneth definitely did *not* write the original question. I've reinstated
the attribution for the OPs question.
>in************ @gmail.com wrote:
>>>Hi,
I did
typedef int Man;

After some code I get a necessity to use the same name Man for char. I
mean to say,I need to
typedef char Man;
But how can I do this???
As others have already said, "you can't" and "why would you want to?"

Perhaps there is more than one programmer involved?

That would be an excellent reason to NOT do it. As others have suggested,
what the OP is trying to do is a very bad idea.
--
Flash Gordon
Sorry, I thought must of the people on here could count angle brackets and
figure out who is being responded to.

Hint: One angle bracket is smaller than two angle brackets, therefore the
response was directed at Kenneth Brody. I am not the least bit interested
as to who *he* responded to. I guess I read "why would you want to" as
"why would you need to" or "how did you get in this predicament". I agree
it is a bad idea and tried not to comment on the advisability of doing that.
The OP had already been told several times not to do it and that he can't.
I tried to respond to what I saw as the "new" thing in the thread.
Nov 16 '06 #8

Eric Sosman wrote:
in************@ gmail.com wrote:
Hi,
I did
typedef int Man;

After some code I get a necessity to use the same name Man for char. I
mean to say,I need to
typedef char Man;
How on Earth did you wind up in that situation?
But how can I do this???

Suggestion #1: Don't.

Suggestion #2: Put the two different `Man' uses in different
scopes. For example, use one typedef in function f() and the
other in function g(), and neither at file scope. Or use one at
file scope in source file a.c and the other in source file b.c,
compiled separately.
Which is still going to be a disaster in its own way. Using the same
name to refer to different types is going to cause problems somewhere
down the line.

It may be time to take a step back and rethink the program's design.

Nov 16 '06 #9
2006-11-16 <4s************ @mid.individual .net>,
osmium wrote:
Hint: One angle bracket is smaller than two angle brackets, therefore the
response was directed at Kenneth Brody. I am not the least bit interested
as to who *he* responded to.
You're still supposed to have exactly as many attribution lines as you
have quote levels. Not more, not less.
Nov 16 '06 #10

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

Similar topics

0
1924
by: Vikas Yadav | last post by:
hi, I have been using a micro$oft mdb with adodb in win32 perl. the problem lately discovred is not ready to get solved. i need to check duplicate and i do a count(*) before insert. what happenbs is count(*) return undef. it was working perfectly earlier and did a lot of work good. but now it does not even run.
2
3628
by: joe | last post by:
hi, after reading some articles and faq, i want to clarify myself what's correct(conform to standard) and what's not? or what should be correct but it isn't simply because compilers don't support. (first i compiled them with g++3.x. ERR means compiler will bark, otherwise it does accept it. Then the Comeau C/C++ 4.3.3 comes)
3
9079
by: Sachin | last post by:
hi, Can i use #undef for undefining a function definition and use my function instead? like described below #undef somefunction1 #define somefunction1(a,b) myfunction1(a,b)
6
7312
by: Alex | last post by:
Hello people, I am getting errors from VS2003 when working with typedef'ed types. For example, assume that I have a type T, defined in a 3rd party include file based on some condition #if (condition) typedef char T; #else typedef short T;
15
2561
by: Ian Bush | last post by:
Hi All, I'm a bit confused by the following which is causing one of our user's codes fail in compilation: typedef struct SctpDest_S; 1) Is this standard ? 2) If so ( or even if not so ! ) what is it supposed to do ?
2
1975
by: Old Wolf | last post by:
Is this program alright? #include <stdio.h> #undef EOF int EOF(void) { return 0; } int main(void) { return EOF(); }
3
2374
by: johnperl | last post by:
Hi, I have a question about the perl 'undef' function. I am using it to read all line at once in once string. In the same script i am using sftp to transfer the file created by the script which uses undef. Now undef is not allowing me to pick the file created on local server and transfer it to another local server. Is there any way to close this undef function? I would appreciate help Thank you in advance john
0
1326
by: myheartinamerica | last post by:
Hello, I was working on a piece of code where a vendor's #define was causing compiler warnings, which led me to try and do the following: #if defined(VAR1) #define VAR1_SAVE VAR1 #undef VAR1 #endif #define VAR1 1
2
3502
by: rasmidas | last post by:
Hi, I am new to Perl and could not understand the below line from an existing Perl Code. undef $/; Could anyone please let me know, what does it do? Thanks in advance. Regards...
0
8473
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
8911
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8819
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
8667
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...
0
7428
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...
1
6222
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
4222
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...
1
2808
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
1806
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.