D
David Rubin
I want to define an inline function, but I need it to be local to my
translation unit. C++PL3ed indicates that the use of 'static' is
deprecated in favor of (unnamed) namespaces. I am confused about where
to put the declaration vs the definition. For example, I think this is
correct:
file.cc
-------
namespace {
inline int port2path(int port);
};
/* ... */
int port2path(int port) {...}
Note that I cannot define port2path in, e.g., file.h, because of the way
file.h is (improperly) used in my codebase. In any case, is it correct
to only declare the function in an unnamed namespace (with inline) and
then define it elsewhere in the file (without inline)?
/david
translation unit. C++PL3ed indicates that the use of 'static' is
deprecated in favor of (unnamed) namespaces. I am confused about where
to put the declaration vs the definition. For example, I think this is
correct:
file.cc
-------
namespace {
inline int port2path(int port);
};
/* ... */
int port2path(int port) {...}
Note that I cannot define port2path in, e.g., file.h, because of the way
file.h is (improperly) used in my codebase. In any case, is it correct
to only declare the function in an unnamed namespace (with inline) and
then define it elsewhere in the file (without inline)?
/david