title: Const and weak attribute with c++ code
body: <p>I am not able to understand the compilation errors below.</p>
  
  <p>First file is a header, <code>test_weak.h</code>:</p>
  
  <pre><code>#ifndef TEST_WEAK_H
  #define TEST_WEAK_H
      #ifndef __ASSEMBLER__
  const char* const TUTU __attribute__((weak)) ="TUTU";
  const char* TUTU_DATE __attribute__((weak)) = __DATE__;
  const char* const tutu ="tutu";
      #endif /*ASSEMBLER*/
  #endif /*TEST_WEAK_H*/
  </code></pre>
  
  <p>Second file is the main <code>test.cpp</code>:</p>
  
  <pre><code>int main ()
  {
    return 42;
  }
  </code></pre>
  
  <p>To compile I run: <code>g++ -include test_weak.h test.cpp -o test</code></p>
  
  <p>Compilation result is : </p>
  
  <pre><code> In file included from &lt;command-line&gt;:0:0:
  ./test_weak.h:5:44: error: weak declaration of ‘TUTU’ must be public
  </code></pre>
  
  <p>I am able to run successfully this code by replacing cpp extension by c extension on test source file and using gcc instead of g++. I am also able to fix this error by removing the weak attribute or removing the second const. So yeah I am able to fix the compilation error but no to able to understand the reason of the problem here.</p>
  
  <p>For example this line compile without trouble: </p>
  
  <pre><code>const char* TUTU __attribute__((weak)) ="TUTU";
  </code></pre>
  
  <p>Why I cannot use a <code>const char* const</code> + weak attribute with c++ ?</p>