470,855 Members | 1,282 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,855 developers. It's quick & easy.

What is the linkage of a namespace scope typedef?

What is the linkage of a namespace scope typedef? Is it internal or
external?

3.5 is unclear on this.

In other words, is the following program, consisting of translation
units a.cpp and b.cpp, well formed?

a.cpp
// file a.cpp
typedef int MyType;
MyType x = 0;

b.cpp:
// file b.cpp

typedef double MyType;
MyType y = 0.0;

int main() { }
May 25 '06 #1
4 3044
red floyd wrote:
What is the linkage of a namespace scope typedef? Is it internal or
external?

3.5 is unclear on this.

In other words, is the following program, consisting of translation
units a.cpp and b.cpp, well formed?

a.cpp
// file a.cpp
typedef int MyType;
MyType x = 0;

b.cpp:
// file b.cpp

typedef double MyType;
MyType y = 0.0;

int main() { }


AFAICT, a 'typedef-name' is a pure compile-time thing and it does
not have linkage (similar to macros). The program above is therefore
well-formed.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 25 '06 #2
red floyd wrote:
What is the linkage of a namespace scope typedef? Is it internal or
external?

3.5 is unclear on this.
Well 8 is pretty clear to me: "If a declaration uses a typedef name,
it is the linkage of the type name to which the typedef refers that is
considered."

A typedef is nothing more than syntactic sugar.
In other words, is the following program, consisting of translation
units a.cpp and b.cpp, well formed?

a.cpp
// file a.cpp
typedef int MyType;
MyType x = 0;

b.cpp:
// file b.cpp

typedef double MyType;
MyType y = 0.0;

int main() { }


Yes it is.
Jonathan

May 25 '06 #3
Jonathan Mcdougall wrote:
red floyd wrote:
What is the linkage of a namespace scope typedef? Is it internal or
external?

3.5 is unclear on this.


Well 8 is pretty clear to me: "If a declaration uses a typedef name,
it is the linkage of the type name to which the typedef refers that is
considered."

A typedef is nothing more than syntactic sugar.


Yeah, I looked at 8 too, and it was just a hard parse for me.

Thanks Victor and Jonathan.
May 25 '06 #4
Jonathan Mcdougall wrote:
red floyd wrote:
What is the linkage of a namespace scope typedef? Is it internal or
external?

3.5 is unclear on this.


Well 8 is pretty clear to me: "If a declaration uses a typedef name,
it is the linkage of the type name to which the typedef refers that is
considered."


To be honest, I had also considered 3.5/8, but still was uncertain.
May 25 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by qazmlp | last post: by
9 posts views Thread by Vipul Jain | last post: by
4 posts views Thread by Peter Ammon | last post: by
6 posts views Thread by Neelesh Bodas | last post: by
13 posts views Thread by fctk | last post: by
7 posts views Thread by akennis | last post: by
3 posts views Thread by toton | last post: by
45 posts views Thread by loudking | last post: by
1 post views Thread by Giacomo Catenazzi | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.