<div dir="ltr">Hey, guys.<div><br></div><div>Before creating a bug report i'd like to know if i'm doing this correct or not.</div><div>Originally it's my <a href="http://stackoverflow.com/questions/32879801/does-llvm-clang-support-weak-attribute-for-weak-linking">SO question</a> but feel free to repond here or on SO.</div><div><br></div><div><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19.5px">I'm learning some Arduino library sources (HardwareSerial.cpp to be more detailed) and i've found some interesting attribute <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(238,238,238)">weak</code> that i've never used before:</p><pre class="" style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">#if defined(HAVE_HWSERIAL0)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">void</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> serialEvent</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> __attribute__</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">((</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">weak</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">));</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">bool</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Serial0_available</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> __attribute__</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">((</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">weak</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">));</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">#endif</span></code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19.5px">I've found it interesting and i've read that linker should set it to NULL if it's not defined.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19.5px">However in my tests with <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(238,238,238)">clang</code> i'm unable to use it.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19.5px">lib.cpp:</p><pre class="" style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">#include</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"lib.h"</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">#include</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)"><stdio.h></span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">void</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> my_weak_func</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> __attribute__</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">((</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">weak</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">));</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">void</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> lib_func</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
printf</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"lib_func()\n"</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">);</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">if</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">my_weak_func</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
my_weak_func</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">();</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">}</span></code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19.5px">lib.h:</p><pre class="" style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">#ifndef</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> LIB_FUNC
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">#define</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> LIB_FUNC
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">void</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> lib_func</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">();</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">#endif</span></code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19.5px">main.cpp:</p><pre class="" style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">#include</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"lib.h"</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">#include</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)"><stdio.h></span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">#ifdef</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> DEFINE_WEAK
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">void</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> my_weak_func</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
printf</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"my_weak_func()\n"</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">);</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">}</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">#endif</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">int</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> main</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
lib_func</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">();</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
printf</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"finished\n"</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">);</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">return</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">;</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">}</span></code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19.5px">if i use <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(238,238,238)">g++ lib.cpp main.cpp -o main -DDEFINE_WEAK</code> i'm able to use it:</p><pre class="" style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">MBA</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Anton</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Weak_issue</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> asmirnov$ </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">./</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">main
lib_func</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
my_weak_func</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
finished</span></code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19.5px">but if i use <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(238,238,238)">g++ lib.cpp main.cpp -o main</code> i'm unable to link the app:</p><pre class="" style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Undefined</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> symbols </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">for</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> architecture x86_64</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"my_weak_func()"</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> referenced from</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
lib_func</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> in lib</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">ceb555</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">o
ld</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> symbol</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">s</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> not found </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">for</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> architecture x86_64
clang</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> error</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> linker command failed with exit code </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">1</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">use </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">v to see invocation</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span></code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19.5px">To be more detailed about clang:</p><pre class="" style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">MBA</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Anton</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Weak_issue</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> asmirnov$ g</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">++</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">--</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">version
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Configured</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> with</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">--</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">prefix</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Applications</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Xcode</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">app</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Contents</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Developer</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">usr </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">--</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">with</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">gxx</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">include</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">dir</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Applications</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Xcode</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">app</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Contents</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Developer</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Platforms</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">MacOSX</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">platform</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Developer</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">SDKs</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">MacOSX10</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">10.sdk</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">usr</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">include</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">c</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">++/</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">4.2</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">1</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Apple</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> LLVM version </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">6.1</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">clang</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">602.0</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">53</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">based on LLVM </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">3.6</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">0svn</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Target</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> x86_64</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">apple</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">-</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">darwin14</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">3.0</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Thread</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> model</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">:</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> posix</span></code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19.5px"><strong style="margin:0px;padding:0px;border:0px">What should i do? Is <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:pre-wrap;background-color:rgb(238,238,238)">weak</code> attribute supported by llvm/clang?</strong></p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;line-height:19.5px">PS. I've already tried to rewrite lib.cpp in the way <a href="https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html" rel="nofollow" style="margin:0px;padding:0px;border:0px;text-decoration:none;color:rgb(12,101,165)">Apple describes</a> and still the same linker error:</p><pre class="" style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">#include</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"lib.h"</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,128,128)">#include</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)"><stdio.h></span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">extern</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">void</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> my_weak_func</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> __attribute__</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">((</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">weak_import</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">));</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">void</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> lib_func</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">()</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">{</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
printf</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">"lib_func()\n"</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">);</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,139)">if</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">my_weak_func </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">!=</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> NULL</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
my_weak_func</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">();</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">}</span></code></pre></div></div>