[Spice-devel] Coding style and naming conventions for C++

Lukáš Hrázký lhrazky at redhat.com
Tue Jan 30 10:09:32 UTC 2018


On Tue, 2018-01-30 at 04:47 -0500, Frediano Ziglio wrote:
> > 
> > 3. Namespace coding style
> > 
> > a) Let's not use `using namespace ...` ever even in .cpp files (see
> > i.e. [1]). In streaming agent we have at the beginning of every
> > .cpp:
> > 
> > using namespace std;
> > using namespace SpiceStreamingAgent;
> > 
> > For namespace std, "std::" is not a long prefix, clearly expresses
> > the
> > identifier is from the standard library and AFAIK most C++ projects
> > use
> > it this way.
> > 
> > For namespace SpiceStreamingAgent, I didn't even know it worked for
> > definition of symbols in the namespace. First time I see it, it is
> > very
> > unusual. see b).
> > 
> 
> Not clear what's unusual here.
> So for every class having something like
> spice::streaming_agent::ClassName ?
> Sounds a bit long.

The way it's (almost universally, AFAIK) done in .cpp is the same as in
the headers, by declaring the namespace scope, as demonstrated:

> > namespace spice {
> > namespace streaming_agent {
> > 
> > THE_CODE
> > 
> > }} // namespace spice::streaming_agent

Lukas


More information about the Spice-devel mailing list