BIND 10 #2358: DBGLVL_xxx should be in .cc, and in specific name space
BIND 10 Development
do-not-reply at isc.org
Mon Oct 15 22:48:43 UTC 2012
#2358: DBGLVL_xxx should be in .cc, and in specific name space
-------------------------------------+-------------------------------------
Reporter: jinmei | Owner:
Type: defect | Status: new
Priority: medium | Milestone: Next-
Component: logging | Sprint-Proposed
Sensitive: 0 | Keywords:
Sub-Project: Core | Defect Severity: N/A
Estimated Difficulty: 0 | Feature Depending on Ticket:
Total Hours: 0 | Add Hours to Ticket: 0
| Internal?: 0
-------------------------------------+-------------------------------------
`DBGLVL_xxx` constants defined in log_dbglevels.h break a couple of
fundamental rules of C++.
- It shouldn't be in unnamed namespace (`namespace {}`). Having it in
a shared header file easily leads to breaking the one definition
rule.
- It shouldn't be defined in the header file. Since they are
constants smart linkers may avoid generating duplicate copies, but
as far as I know it's not guaranteed by the language.
Solution is easy:
- Declare them in a specific namespace, like isc::log
- Only declare them in the header file; define them in a separate .cc:
{{{#!cpp
// in log_dbglevels.h
// This is BAD
//const int DBGLVL_START_SHUT = 0;
extern const int DBGLVL_START_SHUT;
}}}
{{{#!cpp
// in log_dbglevels.cc
const int DBGLVL_START_SHUT = 20;
}}}
--
Ticket URL: <http://bind10.isc.org/ticket/2358>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development
More information about the bind10-tickets
mailing list