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

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 3198
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: qazmlp | last post by:
const has internal linkage in C++, but external linkage in C. Am I right ? But, linker reports multiply-defined error if the following header is included in multiple .cpp files. //...
9
by: Vipul Jain | last post by:
Can any one please tell me what is the difference between global scope of an variable and file scope of an variable. Vipul
4
by: Peter Ammon | last post by:
I would like to share a variable between two functions defined in two separate source files; no other functions will need the global variable so I'd prefer to not give it file scope. Thus, I want...
6
by: Neelesh Bodas | last post by:
Hello All, I was just listing down various ways in which variables can be created and destroyed in C++. (On the lines of 10.4.3 TC++PL Ed 3) Putting the summary here for corrections, comments,...
13
by: fctk | last post by:
source: http://rm-f.net/~orange/devel/specifications/c89-draft.html#3.1.2.2 there are two passages in this paragraph i can't fully understand: 1) "If the declaration of an identifier for an...
7
by: akennis | last post by:
First of all, sorry for duplicating this post. I put it up in the alt.comp.lang.learn.c-c++ mistakenly. I'm investigating a problem whereby exceptions thrown from functions in a Shared Library...
3
by: toton | last post by:
Hi, Is it possible to have a class level namespace opening instead of file level . Something like this, I have a long namespace like namespace com { namespace my_company{ namespace...
45
by: loudking | last post by:
Hello, all I don't quite understand what does ((time_t)-1) mean when I execute "man 2 time" RETURN VALUE On success, the value of time in seconds since the Epoch is retu rned. On error,...
1
by: Giacomo Catenazzi | last post by:
Hello, To learn the details of C, I've build the following example, could you check if it is correct and if it miss some important cases? Are there some useful (real cases) examples of: -...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.