473,387 Members | 1,420 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,387 software developers and data experts.

typedef aliasing

All,

Say I have the following typedef statement:

typedef int * x;

Is it right to say that 'x' is an alias to a pointer-to-int, or that 'x *'
is a an alias to an 'int' ?

thanks,
James
Oct 27 '06 #1
4 1246
James Brown said:
All,

Say I have the following typedef statement:

typedef int * x;

Is it right to say that 'x' is an alias to a pointer-to-int, or that 'x *'
is a an alias to an 'int' ?
Strictly speaking, x is not an alias at all. It's a synonym for the type
"int *". But I for one would not consider it unreasonable to say "x is a
synonym for int *". x *, however, would not mean "int".

typedef int *x; /* x is a synonym for "pointer to int" */

x *p; /* p is a pointer to a pointer to int */

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Oct 27 '06 #2
James Brown <no*@home.netwrote:
Say I have the following typedef statement:
typedef int * x;
Is it right to say that 'x' is an alias to a pointer-to-int
I guess you can call it that. But I would prefer to call it what
it is, a typedef, in order to distinguish it from e.g.

#define x int *

which you also could call an "alias" (perhaps with even more
justification).
or that 'x *' is a an alias to an 'int' ?
No. If you have e.g. a variable definition like

x *y;

'y' will be a pointer-to-pointer-to-int - but I would not call
the "x *" bit an alias, neither for an int nor for pointer-to-
pointer-to-int.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
Oct 27 '06 #3

"Richard Heathfield" <in*****@invalid.invalidwrote in message
news:b4******************************@bt.com...
James Brown said:
>All,

Say I have the following typedef statement:

typedef int * x;

Is it right to say that 'x' is an alias to a pointer-to-int, or that 'x
*'
is a an alias to an 'int' ?

Strictly speaking, x is not an alias at all. It's a synonym for the type
"int *". But I for one would not consider it unreasonable to say "x is a
synonym for int *". x *, however, would not mean "int".

typedef int *x; /* x is a synonym for "pointer to int" */

x *p; /* p is a pointer to a pointer to int */

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
ok thankyou for the clarification.

james
Oct 27 '06 #4

"Jens Thoms Toerring" <jt@toerring.dewrote in message
news:4q************@uni-berlin.de...
James Brown <no*@home.netwrote:
>Say I have the following typedef statement:
>typedef int * x;
>Is it right to say that 'x' is an alias to a pointer-to-int

I guess you can call it that. But I would prefer to call it what
it is, a typedef, in order to distinguish it from e.g.

#define x int *

which you also could call an "alias" (perhaps with even more
justification).
>or that 'x *' is a an alias to an 'int' ?

No. If you have e.g. a variable definition like

x *y;

'y' will be a pointer-to-pointer-to-int - but I would not call
the "x *" bit an alias, neither for an int nor for pointer-to-
pointer-to-int.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
great, thanks for the clarification

james
Oct 27 '06 #5

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

Similar topics

44
by: Carl | last post by:
"Nine Language Performance Round-up: Benchmarking Math & File I/O" http://www.osnews.com/story.php?news_id=5602 I think this is an unfair comparison! I wouldn't dream of developing a numerical...
4
by: Yuri Victorovich | last post by:
In short my question is: If I overload "operator new" for class A and return from it instance of struct B (unrelated with A) as allocated memory area for A should aliasing rules work and allow...
3
by: Michel | last post by:
Is there a way I can anti-aliasing a gif to be able to get a hi-quality resizeable backgroundpicture. When a GIF of JPG is being resized by the browser you get wurse pictures because it needs a...
7
by: Dennis Myrén | last post by:
Hi. Is there any way to define an alias for a type like you could in C++: typedef int NUMBER; I tried using #define but that did not work. Thank you. -- Regards,
12
by: Thomas Carter | last post by:
Imagine that there is some include file f.h that contains the following line: typedef unsigned int ui32 ; My question is: If I have a C source file F.c that includes f.h, is it possible for...
3
by: Hallvard B Furuseth | last post by:
I'm getting horribly lost in the strict aliasing rules. Is this code correct? struct A { int x; }; struct B { int x, y; }; int foo( struct A *a ) { struct B *b = (struct B *) a; return b->x...
4
by: Hyun-jik Bae | last post by:
is there any substitution for typedef int MyType; in C#? Please reply. Thanks in advance. Hyun-jik Bae
7
by: Michal Nazarewicz | last post by:
Let say I have a class template Set which represent set of objects of given type, and a struct template Pair representing an ordered pair, ie: #v+ template<class T> class Set { /* ......
6
by: wongjoekmeu | last post by:
I need to rewrite some typedef to #define. For instance I rewrote typedef void* handle to #define handle void* But I saw for instance another typedef in my code which I don't understand,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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
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...

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.