473,902 Members | 3,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

is "typedef int int;" illegal????

Hi

Suppose you have somewhere

#define BOOL int

and somewhere else

typedef BOOL int;

This gives

typedef int int;

To me, this looks like a null assignment:

a = a;

Would it break something if lcc-win32 would accept that,
maybe with a warning?

Is the compiler *required* to reject that?

Microsoft MSVC: rejects it.
lcc-win32 now rejects it.
gcc (with no flags) accepts it with some warnnings.

Thanks

jacob
---
A free compiler system for windows:
http://www.cs.virginia.edu/~lcc-win32

Mar 24 '06
134 9145
Eric Sosman wrote:
When I spotted the mismatch between your "four standard int types" and
the six columns in the table, I quickly excluded "word" but then
guessed you'd forgotten to count `long long'. It never occurred to me
that you'd, er, recharacterize `char' as a non-integer -- and it seems
a bizarre stance for a C programmer to take.)


Jordan Abel wrote: The keyword "int" is not allowed as part of its type name, therefore it
is arguable that it is not an "int type" despite being an "integer
type".


Exactly. Yes, 'char' is an integer type of C, but it's not an 'int'
type (because 'int' is not allowed as part of its type name).

Doesn't matter anyway; my point is still true that all C compilers
to date (at least those I'm aware of) support two standard integer
types of identical size. Three out of four or four out of five, either
way, there appears to always be a redundant type.

-drt

Mar 27 '06 #61

Jordan Abel wrote:
On 2006-03-27, Eric Sosman <Er*********@su n.com> wrote:
When I spotted the mismatch between your "four standard int types" and
the six columns in the table, I quickly excluded "word" but then
guessed you'd forgotten to count `long long'. It never occurred to me
that you'd, er, recharacterize `char' as a non-integer -- and it seems
a bizarre stance for a C programmer to take.)


The keyword "int" is not allowed as part of its type name, therefore it
is arguable that it is not an "int type" despite being an "integer
type".


Perhaps; but why bother talking about 'int' types in the first place?
Why not discuss "integer" types instead?

Mar 27 '06 #62


David R Tribble wrote On 03/27/06 15:23,:
Eric Sosman wrote:
When I spotted the mismatch between your "four standard int types" and
the six columns in the table, I quickly excluded "word" but then
guessed you'd forgotten to count `long long'. It never occurred to me
that you'd, er, recharacterize `char' as a non-integer -- and it seems
a bizarre stance for a C programmer to take.)


Jordan Abel wrote:
The keyword "int" is not allowed as part of its type name, therefore it
is arguable that it is not an "int type" despite being an "integer
type".

Exactly. Yes, 'char' is an integer type of C, but it's not an 'int'
type (because 'int' is not allowed as part of its type name).

Doesn't matter anyway; my point is still true that all C compilers
to date (at least those I'm aware of) support two standard integer
types of identical size. Three out of four or four out of five, either
way, there appears to always be a redundant type.


Isn't the Alpha under OSF/1 (already mentioned) a
counterexample? It's "four out of four" (or "three out
of three" if you count un-char-itably). If you want to
look from the other angle, it has no "redundant" type.

--
Er*********@sun .com

Mar 27 '06 #63


Jordan Abel wrote On 03/27/06 15:07,:

a 128-bit word size might make sense, though, for a specialized system
that is intended to mainly work with high-precision floating point,
though. [...]


Not a mere theoretical possibility: DEC VAX supported
four floating-point formats, one of which (H-format) used
128 bits. The small-VAX models I used implemented H-format
with trap-and-emulate, but it was part of the instruction
architecture nonetheless and in that sense a "native" form.

--
Er*********@sun .com

Mar 27 '06 #64
Eric Sosman <Er*********@su n.com> writes:
[...]
Doesn't matter anyway; my point is still true that all C compilers
to date (at least those I'm aware of) support two standard integer
types of identical size. Three out of four or four out of five, either
way, there appears to always be a redundant type.


Isn't the Alpha under OSF/1 (already mentioned) a
counterexample? It's "four out of four" (or "three out
of three" if you count un-char-itably). If you want to
look from the other angle, it has no "redundant" type.


Alpha OSF/1 has the following:

char 8
short 16
int 32
long 64
long long 64

It has no redundant type only if you ignore C99.

In any case, redundant types aren't necessarily a bad thing. The
standard guarantees a minimum range for each type, and requires a
reasonably large set of types to be mapped onto the native types of
the underlying system. Having some types overlap is better than
leaving gaps.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 27 '06 #65
On 2006-03-27, Eric Sosman <Er*********@su n.com> wrote:


Jordan Abel wrote On 03/27/06 15:07,:

a 128-bit word size might make sense, though, for a specialized system
that is intended to mainly work with high-precision floating point,
though. [...]


Not a mere theoretical possibility: DEC VAX supported
four floating-point formats, one of which (H-format) used
128 bits. The small-VAX models I used implemented H-format
with trap-and-emulate, but it was part of the instruction
architecture nonetheless and in that sense a "native" form.


I'm talking about a hypothetical machine that used 128 bits for
everything, as some allegedly now use 32 bits for everything.
Mar 27 '06 #66
On 2006-03-27, Keith Thompson <ks***@mib.or g> wrote:
Jordan Abel <ra*******@gmai l.com> writes:
On 2006-03-27, Eric Sosman <Er*********@su n.com> wrote:
When I spotted the mismatch between your "four standard int types" and
the six columns in the table, I quickly excluded "word" but then
guessed you'd forgotten to count `long long'. It never occurred to me
that you'd, er, recharacterize `char' as a non-integer -- and it seems
a bizarre stance for a C programmer to take.)
The keyword "int" is not allowed as part of its type name, therefore it
is arguable that it is not an "int type" despite being an "integer
type".


The language makes no such distinction.


We have short ints, long ints, and no char ints. that's a language
distinction if there ever was one. "int type" isn't really a term
defined by the language anyway, and arguably one plausible definition is
"types declared using the keyword 'int'".
Type char is an integer type;
the only thing that's really special about it is that plain char may
be either signed or unsigned.

Mar 27 '06 #67
Jordan Abel <ra*******@gmai l.com> writes:
On 2006-03-27, Keith Thompson <ks***@mib.or g> wrote:
Jordan Abel <ra*******@gmai l.com> writes:
On 2006-03-27, Eric Sosman <Er*********@su n.com> wrote:
When I spotted the mismatch between your "four standard int types" and
the six columns in the table, I quickly excluded "word" but then
guessed you'd forgotten to count `long long'. It never occurred to me
that you'd, er, recharacterize `char' as a non-integer -- and it seems
a bizarre stance for a C programmer to take.)

The keyword "int" is not allowed as part of its type name, therefore it
is arguable that it is not an "int type" despite being an "integer
type".


The language makes no such distinction.


We have short ints, long ints, and no char ints. that's a language
distinction if there ever was one. "int type" isn't really a term
defined by the language anyway, and arguably one plausible definition is
"types declared using the keyword 'int'".


We also have "short", "unsigned short", "unsigned", "long", "unsigned
long", etc.

If I wanted to define the term "int type", I suppose "any type that
*can* be declared using the keyword 'int'" might be a plausible
definition. However, the standard doesn't define such a term (any
more than it groups long, unsigned long, long long, unsigned long
long, and long double as "long types").

I see absolutely no point either in defining such a term or in
continuing this discussion.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 27 '06 #68
On 27 Mar 2006 08:44 -0800, "David R Tribble" wrote:
Wojtek Lerch wrote:
BTW Think about
typedef long long long long;
;-)

Stephen Sprunk wrote:
That "long long" even exists is a travesty.

What are we going to do when 128-bit ints become common in another couple
decades? Call them "long long long"? Or if we redefine "long long" to be
128-bit ints and "long" to be 64-bit ints, will a 32-bit int be a "short
long" or a "long short"? Maybe 32-bit ints will become "short" and 16-bit
ints will be a "long char" or "short short"? Or is a "short short" already
equal to a "char"?

All we need are "int float" and "double int" and the entire C type system
will be perfect! </sarcasm>


It's interesting to note that most implementations (all of them I've
ever seen, in fact) only provide three of the four standard int type
sizes, with two of the four being the same size. For example,
consider the following typical choices of type sizes for various
CPU word sizes:

word | char | short| int | long | long long
-----+------+------+------+------+----------


data structure and its size effect heavy for portability (because when
i has the data of the same size & ^ | etc for them should be all well
definite the same) so all problem on portability disappear

so to use char, int, short, long, etc is an error if someone sees
portability for a program.
they had been int8, int16, int32, etc (until char int8) from the day 1
uns8, uns16 uns32 etc
the problem could be that different cpu has different 'main' word size
and this effect in efficience
Mar 28 '06 #69
Stephen Sprunk wrote:
That "long long" even exists is a travesty.
Hardly. The need for something along those lines was so pressing
that different compiler vendors had invented a variety of solutions
already, including some using "long long".
What are we going to do when 128-bit ints become common in another couple
decades?


Use int_least128_t if you need a standard name for a signed int
with width at least 128 bits. If you don't know what that is,
here's an opportunity to learn.
Mar 28 '06 #70

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

Similar topics

6
3746
by: Fao | last post by:
Hi, I am in my first year of C++ in college and my professor wants me to Write a Program with multiple functions,to input two sets of user-defined data types: One type named 'Sign' declared by "typedef" to contain only either +10 or -10 and the other type named Color declared by "enum" to contain only black, blue, purple, red, white, and yellow.
0
9997
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
9673
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
8047
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
7205
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
5893
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
6085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4725
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
4306
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3323
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.