473,385 Members | 2,004 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,385 software developers and data experts.

question about anonymous namespace...

I am reading the book "C++ Annotations", and here is a quote from the
book:

Namespaces can be defined without a name. Such a namespace is
anonymous and it restricts the
visibility of the defined entities to the source file in which the
anonymous namespace is defined.
Entities defined in the anonymous namespace are comparable to C’s
static functions and variables.
In C++ the static keyword can still be used, but its use is more
common in class definitions
(see chapter 6). In situations where static variables or functions are
necessary, the use of the
anonymous namespace is preferred.
--------------

Could anybody give me an example about why the anonymous name space is
the same as "static" variables and functions in C?

thanks!
Oct 22 '08 #1
22 3870
Luna Moon wrote:
I am reading the book "C++ Annotations", and here is a quote from the
book:

Namespaces can be defined without a name. Such a namespace is
anonymous and it restricts the
visibility of the defined entities to the source file in which the
anonymous namespace is defined.
Entities defined in the anonymous namespace are comparable to C’s
static functions and variables.
In C++ the static keyword can still be used, but its use is more
common in class definitions
(see chapter 6). In situations where static variables or functions are
necessary, the use of the
anonymous namespace is preferred.
--------------

Could anybody give me an example about why the anonymous name space is
the same as "static" variables and functions in C?
The quote says it all: "it restricts the visibility of the defined
entities to the source file in which the anonymous namespace is defined"

Which is exactly what "static" does in C.

--
Ian Collins
Oct 22 '08 #2
In article
<4b**********************************@a29g2000pra. googlegroups.com>, Luna
Moon <lu**********@gmail.comwrote:
I am reading the book "C++ Annotations", and here is a quote from the
book:

Namespaces can be defined without a name. Such a namespace is
anonymous and it restricts the visibility of the defined entities
to the source file in which the anonymous namespace is defined.
Entities defined in the anonymous namespace are comparable to C's
static functions and variables. In C++ the static keyword can still
be used, but its use is more common in class definitions (see
chapter 6). In situations where static variables or functions are
necessary, the use of the anonymous namespace is preferred.

--------------

Could anybody give me an example about why the anonymous name space is
the same as "static" variables and functions in C?
Why? Because the standard says so. Actually, the effect is not exactly the same.

// Before namespace
static int i;
static void f() { }
struct my_foo { };

// After namespace
namespace
{
int i;
void f() { }
struct foo { }; // no need for prefix on name, since it's now a local name
}

BTW, the proper term is "unnamed namespace" (C++03 7.3.1.1). The author of
the C++ book you're reading should have taken the time to get it right.
Oct 23 '08 #3
On Oct 23, 9:08 am, blargg....@gishpuppy.com (blargg) wrote:
In article
<4b97d33c-17f1-4bf8-a02b-71ca05250...@a29g2000pra.googlegroups.com>,
Luna Moon <lunamoonm...@gmail.comwrote:
[...]
Could anybody give me an example about why the anonymous
name space is the same as "static" variables and functions
in C?
Why? Because the standard says so. Actually, the effect is not
exactly the same.
// Before namespace
static int i;
static void f() { }
struct my_foo { };
// After namespace
namespace
{
int i;
void f() { }
struct foo { }; // no need for prefix on name, since it's now a localname
}
Another important difference is the linkage of the name. A
static variable or function has internal linkage. A name in an
anonymous namespace has external linkage---the reason it can't
be seen from other translation units is that it isn't namable in
them. (Formally, it is visible everywhere, but since it can't
be named, there's no way to actually see it.) A template can
only be instantiated over something that has external linkage,
e.g.:

template< int* p class T {} ;

static int i ;
namespace {
int j ;
}

T< &i ti ; // illegal...
T< &j tj ; // legal.
BTW, the proper term is "unnamed namespace" (C++03 7.3.1.1).
The author of the C++ book you're reading should have taken
the time to get it right.
The term anonymous namespace seems pretty widespread to me.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Oct 23 '08 #4
... A template can only be instantiated over something that
has external linkage, e.g.:

template< int* p class T {} ;

static int i ;
namespace {
int j ;
}

T< &i ti ; // illegal...
T< &j tj ; // legal.
To me, anonymous namespaces were just the C++ way of saying static.
The external linkage point is new to me. But:

Pointer-to-int as template argument? Instantiating templates over
something with external linkage? Could you provide a practical example
working with anonymous namespace but not working with static? Note
that you could also omit the static keyword to the same effect.
BTW, the proper term is "unnamed namespace" (C++03 7.3.1.1).
The author of the C++ book you're reading should have taken
the time to get it right.

The term anonymous namespace seems pretty widespread to me.
I'd bet a horse and a carrot that "unnamed" is the literal meaning of
"anonymous".

Best regards,
Andreas.
Oct 23 '08 #5
On Oct 23, 3:08*am, blargg....@gishpuppy.com (blargg) wrote:

[snip]
// Before namespace
static int i;
static void f() { }
struct my_foo { };

// After namespace
namespace
{
* * int i;
* * void f() { }
* * struct foo { }; // no need for prefix on name, since it's now a local name

}

Now I'm curious. Take the following code from the same compilation
unit:

namespace
{
int i;
void x() { }
}

namespace
{
int j;
void y() { }
}

Would i be visible to y(), and j be visible to x()?
Oct 23 '08 #6
On 2008-10-23 12:23:54 -0400, Michael Mol <mi*****@gmail.comsaid:
On Oct 23, 3:08Â*am, blargg....@gishpuppy.com (blargg) wrote:

[snip]
>// Before namespace
static int i;
static void f() { }
struct my_foo { };

// After namespace
namespace
{
Â* Â* int i;
Â* Â* void f() { }
Â* Â* struct foo { }; // no need for prefix on name, since it's now a l
ocal name
>>
}


Now I'm curious. Take the following code from the same compilation
unit:

namespace
{
int i;
void x() { }
}

namespace
{
int j;
void y() { }
}

Would i be visible to y(),
yes.
and j be visible to x()?
no.

Same answer with a named namespace and without a namespace.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

Oct 23 '08 #7
Now I'm curious. Take the following code from the same compilation
unit:

namespace
{
int i;
void x() { }
}

namespace
{
int j;
void y() { }
}

Would i be visible to y(), and j be visible to x()?
Generally, namespaces can be split across several compilation units.
The only exception to this rule are anonymous namespaces. If you would
split an anonymous namespace across several compilation units, it
wouldn't be the same namespace. That's because anonymous namespaces
are not truely anonymous, it's just that their name is not accessible
by the coder. The compiler, however, assigns a unique ID to them per
compilation unit.

But, as you're asking for the same compilation unit, yes, i is visible
to y(), and no, j is not visible to x().

Best regards,
Andreas.
Oct 23 '08 #8
In article
<34**********************************@g61g2000hsf. googlegroups.com>,
Michael Mol <mi*****@gmail.comwrote:
On Oct 23, 3:08 am, blargg....@gishpuppy.com (blargg) wrote:

[snip]
// Before namespace
static int i;
static void f() { }
struct my_foo { };

// After namespace
namespace
{
int i;
void f() { }
struct foo { }; // no need for prefix on name, since it's now a
// local name

}

Now I'm curious. Take the following code from the same compilation
unit:

namespace
{
int i;
void x() { }
}

namespace
{
int j;
void y() { }
}

Would i be visible to y(), and j be visible to x()?
Heck, since we're talking about the same translation unit, you could also add

// at file scope in same translation unit
void z()
{
i = 0;
j = 0;
x();
y();
}

and it would see everything in your unnamed namespaces (and z would be
visible to other translation units).
Oct 23 '08 #9
On Oct 23, 5:35*pm, "spamboun...@gmx.de" <spamboun...@gmx.dewrote:
... A template can only be instantiated over something that
has external linkage, e.g.:
* * template< int* p class T {} ;
* * static int i ;
* * namespace {
* * * * int j ;
* * }
* * T< &i ti ; * // *illegal...
* * T< &j tj ; * // *legal.
To me, anonymous namespaces were just the C++ way of saying
static. The external linkage point is new to me. But:
Pointer-to-int as template argument?
Why not? It was the simplest example that came to my mind.
Instantiating templates over something with external linkage?
Anything you use to instantiate a template must have external
linkage. Those are the rules.
Could you provide a practical example working with anonymous
namespace but not working with static?
I just did. See above: declare the variable static, and you
can't use it to instantiate the template. Define it in an
anonymous namespace, and you can.

I run into this a lot because of const; const is static by
default, so something like:

template< int* p class T{} ;

namespace {
int const i = 43 ;
}

T< &i t ; // illegal.

You have to define the int:
extern int const i = 43 ;

(In practice, of course, most of the time, it's a user defined
class, and the template parameter is a reference, rather than a
pointer, and it's a function template, not a class template.
But the same principles apply.)
Note that you could also omit the static keyword to the same
effect.
Except that if I omitted the static keyword in my example, the
symbol would be visible in every module. And conflict with
another module which did exactly the same thing with the same
name.
BTW, the proper term is "unnamed namespace" (C++03 7.3.1.1).
The author of the C++ book you're reading should have taken
the time to get it right.
The term anonymous namespace seems pretty widespread to me.
I'd bet a horse and a carrot that "unnamed" is the literal
meaning of "anonymous".
Actually, no. From the way I understand English, anonymous
means that the name is hidden, and not visible; unnamed means
that it doesn't exist. In which case, anonymous is actually
closer to what really happens.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Oct 23 '08 #10
James Kanze wrote:
On Oct 23, 5:35 pm, "spamboun...@gmx.de" <spamboun...@gmx.dewrote:
[...]
>I'd bet a horse and a carrot that "unnamed" is the literal
meaning of "anonymous".

Actually, no. From the way I understand English, anonymous
means that the name is hidden, and not visible; unnamed means
that it doesn't exist. In which case, anonymous is actually
closer to what really happens.
According to my dictionary, "anonymous" derives from an old
Latin word which derives from a Greek word, consisting of "an"
("without") and "onuma" ("name"), and meaning "nameless".
I know, of course, that this leaves a lot of room for a debate
about whether today this actually is "the literal meaning" of
the word or not... However, my dictionary then produces "having
an unknown or unacknowledged name" as the first of the three
meanings it comes up with. (And now there's room for a debate
whether my dictionary is actually worth anything...)

Schobi
Oct 23 '08 #11
On Oct 23, 9:27*am, Pete Becker <p...@versatilecoding.comwrote:
On 2008-10-23 12:23:54 -0400, Michael *Mol <mike...@gmail.comsaid:


On Oct 23, 3:08*am, blargg....@gishpuppy.com (blargg) wrote:
[snip]
// Before namespace
static int i;
static void f() { }
struct my_foo { };
// After namespace
namespace
{
* * int i;
* * void f() { }
* * struct foo { }; // no need for prefix on name, since it's now a l
ocal name
}
Now I'm curious. *Take the following code from the same compilation
unit:
namespace
{
* * int i;
* * void x() { }
}
namespace
{
* * int j;
* * void y() { }
}
Would i be visible to y(),

yes.
*and j be visible to x()?

no.

Same answer with a named namespace and without a namespace.
Why the above answers Pete? Thanks!
Oct 23 '08 #12
On Oct 22, 4:05*pm, Ian Collins <ian-n...@hotmail.comwrote:
Luna Moon wrote:
I am reading the book "C++ Annotations", and here is a quote from the
book:
Namespaces can be defined without a name. Such a namespace is
anonymous and it restricts the
visibility of the defined entities to the source file in which the
anonymous namespace is defined.
Entities defined in the anonymous namespace are comparable to C’s
static functions and variables.
In C++ the static keyword can still be used, but its use is more
common in class definitions
(see chapter 6). In situations where static variables or functions are
necessary, the use of the
anonymous namespace is preferred.
--------------
Could anybody give me an example about why the anonymous name space is
the same as "static" variables and functions in C?

The quote says it all: "it restricts the visibility of the defined
entities to the source file in which the anonymous namespace is defined"

Which is exactly what "static" does in C.

--
Ian Collins- Hide quoted text -

- Show quoted text -
I thought "static" means "persistent", are the anonymous name space
persistent?

If you define "static" in a function, it will only get initialized
once and can be used forever...

Oct 23 '08 #13
Luna Moon wrote:
On Oct 22, 4:05 pm, Ian Collins <ian-n...@hotmail.comwrote:
>Luna Moon wrote:
>>I am reading the book "C++ Annotations", and here is a quote from the
book:
Namespaces can be defined without a name. Such a namespace is
anonymous and it restricts the
visibility of the defined entities to the source file in which the
anonymous namespace is defined.
Entities defined in the anonymous namespace are comparable to C’s
static functions and variables.
In C++ the static keyword can still be used, but its use is more
common in class definitions
(see chapter 6). In situations where static variables or functions are
necessary, the use of the
anonymous namespace is preferred.
--------------
Could anybody give me an example about why the anonymous name space is
the same as "static" variables and functions in C?
The quote says it all: "it restricts the visibility of the defined
entities to the source file in which the anonymous namespace is defined"

Which is exactly what "static" does in C.
Last signature warning!
>
I thought "static" means "persistent", are the anonymous name space
persistent?

If you define "static" in a function, it will only get initialized
once and can be used forever...
Static in the context of C and linkage. It's unfortunate that both C
and C++ overload the meaning of static. Attempting to remove this
ambiguity is probably one of the reasons C++ introduced the unnamed
namespace.

--
Ian Collins
Oct 23 '08 #14
On 2008-10-23 17:19:58 -0400, Luna Moon <lu**********@gmail.comsaid:
On Oct 23, 9:27Â*am, Pete Becker <p...@versatilecoding.comwrote:
>On 2008-10-23 12:23:54 -0400, Michael Â*Mol <mike...@gmail.comsaid:


>>On Oct 23, 3:08Â*am, blargg....@gishpuppy.com (blargg) wrote:
>>[snip]
>>>// Before namespace
static int i;
static void f() { }
struct my_foo { };
>>>// After namespace
namespace
{
Â* Â* int i;
Â* Â* void f() { }
Â* Â* struct foo { }; // no need for prefix on name, since it's now
a l
>>ocal name
>>>}
>>Now I'm curious. Â*Take the following code from the same compilation
unit:
>>namespace
{
Â* Â* int i;
Â* Â* void x() { }
}
>>namespace
{
Â* Â* int j;
Â* Â* void y() { }
}
>>Would i be visible to y(),

yes.
>>Â*and j be visible to x()?

no.

Same answer with a named namespace and without a namespace.

Why the above answers Pete? Thanks!
The above answers were intended to inspire thinking and experimenting.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

Oct 23 '08 #15
On 23 Okt., 22:52, Hendrik Schober <spamt...@gmx.dewrote:
James Kanze wrote:
On Oct 23, 5:35 pm, "spamboun...@gmx.de" <spamboun...@gmx.dewrote:
[...]
I'd bet a horse and a carrot that "unnamed" is the literal
meaning of "anonymous".
Actually, no. *From the way I understand English, anonymous
means that the name is hidden, and not visible; unnamed means
that it doesn't exist. *In which case, anonymous is actually
closer to what really happens.

* According to my dictionary, "anonymous" derives from an old
* Latin word which derives from a Greek word, consisting of "an"
* ("without") and "onuma" ("name"), and meaning "nameless".
* I know, of course, that this leaves a lot of room for a debate
* about whether today this actually is "the literal meaning" of
* the word or not... However, my dictionary then produces "having
* an unknown or unacknowledged name" as the first of the three
* meanings it comes up with. (And now there's room for a debate
* whether my dictionary is actually worth anything...)

* Schobi
But your dictionary seems to agree with James Kanze, right? anonymous
= unknown name, unnamed = has no name. Regarding the etymology, it is
quite normal that the original meaning of a word changes meaning over
time.

/Peter
Oct 23 '08 #16
Luna Moon wrote:
[...]
I thought "static" means "persistent", are the anonymous name space
persistent?
'static' is one of the (if not the) most overloaded keywords in
C and C++. It means different things in different contexts.
[...]
Schobi
Oct 24 '08 #17
On Oct 23, 11:21 pm, Luna Moon <lunamoonm...@gmail.comwrote:
On Oct 22, 4:05 pm, Ian Collins <ian-n...@hotmail.comwrote:
I thought "static" means "persistent", are the anonymous name
space persistent?
In C++, the static keyword is very overloaded. It can affect
linkage or lifetime, or both, depending on where it is used.
When used with a local variable, it means static lifetime, which
corresponds more or less to the general English meaning (not to
be confused with persistent, which is usually used to mean that
the lifetime extends beyond the execution of the program). If
you apply it to a function or variable at namespace scope,
however, it means internal linkage---the opposite of extern
(more or less: extern can also mean that the declaration is not
a definition---the actual rules are not at all orthogonal).

All variables declared at namespace scope have static lifetime,
whether they are declared with the keyword static or not.
Member variables declared with the static keyword also have
static lifetime; without the static keyword, they have the
lifetime of the containing object. Variables defined with
local scope have static lifetime if defined with the static
keyword, automatic otherwise.

Functions don't have lifetime, in the sense C++ defines it;
they're just there.
If you define "static" in a function, it will only get
initialized once and can be used forever...
Not forever. Only until the end of the program. A persistent
variable could be used forever, but there is no direct support
for this in the language; you have to implement it yourself.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Oct 24 '08 #18
On Oct 24, 12:13 am, peter koch <peter.koch.lar...@gmail.comwrote:
On 23 Okt., 22:52, Hendrik Schober <spamt...@gmx.dewrote:
James Kanze wrote:
On Oct 23, 5:35 pm, "spamboun...@gmx.de" <spamboun...@gmx.dewrote:
[...]
>I'd bet a horse and a carrot that "unnamed" is the
>literal meaning of "anonymous".
Actually, no. From the way I understand English,
anonymous means that the name is hidden, and not visible;
unnamed means that it doesn't exist. In which case,
anonymous is actually closer to what really happens.
According to my dictionary, "anonymous" derives from an
old Latin word which derives from a Greek word, consisting
of "an" ("without") and "onuma" ("name"), and meaning
"nameless". I know, of course, that this leaves a lot of
room for a debate about whether today this actually is
"the literal meaning" of the word or not... However, my
dictionary then produces "having an unknown or
unacknowledged name" as the first of the three meanings it
comes up with. (And now there's room for a debate whether
my dictionary is actually worth anything...)
But your dictionary seems to agree with James Kanze, right?
anonymous = unknown name, unnamed = has no name. Regarding the
etymology, it is quite normal that the original meaning of a
word changes meaning over time.
In everyday English, words can also be a bit ambiguous. I'm
pretty sure that a native English speaker would "feel" a
difference (at least a nuace of a difference) between anonymous
and unnamed, but there is also some overlap in the meanings. In
technical fields, we then specialize the meaning, so that it is
exact.

I did a quick find on the standard; all uses of anonymous were
for anonymous unions or anonymous bit fields, so Hendrik is
probably right that we should be talking about unnamed unions.
Regardless of the appropriateness of the term, based on its
natural English use, it's the formal term used in the standard.
Or "we should have been talking about unnamed namespace":
regardless of the standard terminology, "anonymous namespace"
has been adopted by the technical experts to describe this
feature, and is widely understood and used; in this specialized,
technical sense, anonymous and unnamed are exact synonyms, and
you can pretty much use them interchangeably without causing
problems of understanding.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Oct 24 '08 #19
On 24 Okt., 09:36, James Kanze <james.ka...@gmail.comwrote:
...
regardless of the standard terminology, "anonymous namespace"
has been adopted by the technical experts to describe this
feature, and is widely understood and used; in this specialized,
technical sense, anonymous and unnamed are exact synonyms, and
you can pretty much use them interchangeably without causing
problems of understanding.
There you go. Geez, people! What a debate! My betting a horse was
supposed to end the nitpicking. It wasn't a real horse, see. There
wasn't the slightest ambiguity to begin with. Everyone knew exactly
what we were talking about.

Ok, who wants the carrot?
Oct 24 '08 #20
On 2008-10-24 04:20:39 -0400, "sp*********@gmx.de" <sp*********@gmx.desaid:
On 24 Okt., 09:36, James Kanze <james.ka...@gmail.comwrote:
>...
regardless of the standard terminology, "anonymous namespace"
has been adopted by the technical experts to describe this
feature, and is widely understood and used; in this specialized,
technical sense, anonymous and unnamed are exact synonyms, and
you can pretty much use them interchangeably without causing
problems of understanding.

There you go. Geez, people! What a debate! My betting a horse was
supposed to end the nitpicking. It wasn't a real horse, see.
Indeed. It didn't even have a name.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

Oct 24 '08 #21
Pete Becker wrote:
On 2008-10-24 04:20:39 -0400, "sp*********@gmx.de" <sp*********@gmx.de>
said:
>On 24 Okt., 09:36, James Kanze <james.ka...@gmail.comwrote:
>>...
regardless of the standard terminology, "anonymous namespace"
has been adopted by the technical experts to describe this
feature, and is widely understood and used; in this specialized,
technical sense, anonymous and unnamed are exact synonyms, and
you can pretty much use them interchangeably without causing
problems of understanding.

There you go. Geez, people! What a debate! My betting a horse was
supposed to end the nitpicking. It wasn't a real horse, see.

Indeed. It didn't even have a name.
That took me a minute.

Anyway, don't knock it 'till you try it. You see, I've been through the
desert on a horse with no name. (In the desert, you forget your name,
so I guess the horse was really more "anonymous" than "unnamed.")
Oct 24 '08 #22
James Kanze wrote:
[...]
>But your dictionary seems to agree with James Kanze, right?
anonymous = unknown name, unnamed = has no name. Regarding the
etymology, it is quite normal that the original meaning of a
word changes meaning over time.

In everyday English, words can also be a bit ambiguous. I'm
pretty sure that a native English speaker would "feel" a
difference (at least a nuace of a difference) between anonymous
and unnamed, but there is also some overlap in the meanings. In
technical fields, we then specialize the meaning, so that it is
exact.
FWIW, I feel the difference, too. However I can see "unnamed" as
deriving either from the substantive "name" or the verb "to
name", in which case it sound as "is not named". And my mind
leans towards the latter meaning when I add "nameless" to the
mix :-)

--
Gennaro Prota | name.surname yahoo.com
Breeze C++ (preview): <https://sourceforge.net/projects/breeze/>
Do you need expertise in C++? I'm available.
Oct 24 '08 #23

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

Similar topics

8
by: Jason Heyes | last post by:
I wrote: namespace { void f(); } void f() { std::cout << "hello world" << std::endl; } When I compile, I receive this error: unresolved external symbol "bool __cdecl `anonymous...
3
by: Frederick Gotham | last post by:
Back in the day, if you wanted a function to be self-contained within a translation unit, you defined the function as "static". If there were an external linkage function by the same name...
1
by: wenmang | last post by:
Hi, I try to use variables declared in anonymous namespace as file scope vars. But, during the debugging effort, those variables are not visible to debugger, how can I access those vars? thx
12
by: Taras_96 | last post by:
Hi everyone, AFAIK external linkage allows you to refer to variables/functions outside of the current translation unit. A variable in an unnamed namespace is similar to declaring a static...
5
by: gauravbjain | last post by:
I am planning to move from ‘static’ keyword to anonymous namespace for variables/functions which are local to a translation unit. This is to move code closer to C++, since static for file level...
3
by: Al Grant | last post by:
Consider two translation units, (1): namespace { struct S { }; } struct D: S { virtual int f(void); }; and (2): #include <typeinfo> struct D; char const *f(D *p) { return...
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
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.