Sujet : Re: question about linker
De : jameskuyper (at) *nospam* alumni.caltech.edu (James Kuyper)
Groupes : comp.lang.cDate : 12. Dec 2024, 05:38:52
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vjdpct$1viqk$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
User-Agent : Mozilla Thunderbird
On 12/10/24 20:32, Scott Lurndal wrote:
James Kuyper <jameskuyper@alumni.caltech.edu> writes:
On 12/4/24 15:55, David Brown wrote:
On 04/12/2024 16:09, Bart wrote:
...
In C struct, union, and enumation tags have their own namespace, in C++
they reside in the ordinary name space.
In C++ they reside in the ordinary name space only if they're not
part of a named namespace.
namespace x {
int y;
};
You're confusing name spaces and namespaces.
Your example does not include any struct, union, or enumeration tags, so
it's not directly relevant to what I said.
Because tags name types, the fact that they are in the same namespace as
other identifiers is most easily shown using typedefs, which are also in
the ordinary name space.
The following code is permitted in C, even though both declarations are
in the same scope, because 'y' is declared in two different name spaces:
typedef int y;
struct y { int z;};
However, in C++ it is not permitted because both occurrences of 'y' are
in the same name space. That's equally true whether they occur in the
same named namespace or the same unnamed namespace.