[PATCH] D29167: [compiler-rt] [sancov] Move __sancov_default_options declaration outside the namespace __sancov

Marcos Pividori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 29 23:12:18 PST 2017


mpividori added a comment.

@kcc 
If we define `__sancov_default_options` inside a namespace, it will be ignored, and it will be included with 'C' linkage.

  // somefile.cc
  namespace  __sancov {
     extern "C" const char* __sancov_default_options() { return ""; }
  }

But if we declare it inside a namespace like:

  // somefile.h
  namespace  __sancov {
     extern "C" void __sancov_default_options();
  }

I need to add the namespace when using it. (even though the compiler will add an external undefined symbol with 'C' linkage, without the namespace)

  // main.cc
  #include "somefile.h"
  int main() {
    somenamespace::somefun();
    return 0;
  }

So, because of that I simply move the external declaration outside the namespace. So, I can refer to it as `somefun()` without the namespace.


https://reviews.llvm.org/D29167





More information about the llvm-commits mailing list