[cfe-dev] [RFC] __attribute__((internal_linkage))
Evgenii Stepanov via cfe-dev
cfe-dev at lists.llvm.org
Fri Oct 23 14:41:16 PDT 2015
Sounds right. The proposed attribute is a rough equivalent of
static void foo::do_method(void)
{
// implementation here
}
where "static" does not mean a static class member, but makes the
declaration local to the translation unit. C-style "static".
The patch in http://reviews.llvm.org/D13925 (waiting for review, btw!)
supports this attribute on classes and namespaces, with this syntax:
namespace __attribute__((internal_linkage)) {
}
On Fri, Oct 23, 2015 at 9:03 AM, Steven Stewart-Gallus via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> Hello,
>
> Can I ask for some clarification?
>
> Apparently, C++ doesn't allow to static class methods?
>
> While in C one might write inside a header file:
>
> static inline void mylib_foo_do_method(struct mylib_foo *foo) {
> // implementation here
> }
>
> In C++ the typical style would be to write something like:
>
> namespace mylib {
>
> void foo::do_method(void)
> {
> // implementation here
> }
> }
>
> Unfortunately, the C++ case then implies some linkage behaviour that
> some might not want.
>
> Apparently, one can't do things like:
>
> namespace mylib {
>
> static void foo::do_method(void)
> {
> // implementation here
> }
> }
>
> Or,
>
> namespace {
> namespace mylib {
>
> static void foo::do_method(void)
> {
> // implementation here
> }
> }
> }
>
> Also, if you wanted to an attribute to a whole namespace you should do
> something like the following I think:
>
> namespace mylib {
> [[clang::internal_linkage]];
>
> static void foo::do_method(void)
> {
> // implementation here
> }
> }
>
>
> Thank you,
> Steven Stewart-Gallus
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list