Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions llvm/docs/CodingStandards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -860,23 +860,28 @@ your private interface remains private and undisturbed by outsiders.
It's okay to put extra implementation methods in a public class itself. Just
make them private (or protected) and all is well.

Use Namespace Qualifiers to Implement Previously Declared Functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Use Namespace Qualifiers to Define Previously Declared Variables and Functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

When providing an out-of-line implementation of a function in a source file, do
not open namespace blocks in the source file. Instead, use namespace qualifiers
to help ensure that your definition matches an existing declaration. Do this:
When providing an out-of-line definition of a variable or a function in a source
file, do not open namespace blocks in the source file. Instead, use namespace
qualifiers to help ensure that your definition matches an existing declaration.
Do this:

.. code-block:: c++

// Foo.h
namespace llvm {
extern int FooVal;
int foo(const char *s);
}

// Foo.cpp
#include "Foo.h"
using namespace llvm;

int llvm::FooVal;

int llvm::foo(const char *s) {
// ...
}
Expand Down
Loading