<div dir="ltr">This was <a href="https://llvm.org/bugs/show_bug.cgi?id=20746">https://llvm.org/bugs/show_bug.cgi?id=20746</a>.<div><br></div><div>In simple cases, this is just a warning:</div><div><div>$ cat t.c</div><div>void Sleep(unsigned long MS);</div><div>void __declspec(dllimport) Sleep(unsigned long MS);</div><div>$ clang -c t.c</div><div>t.c:2:28: warning: redeclaration of 'Sleep' should not add 'dllimport' attribute [-Wdll-attribute-on-redeclaration]</div><div><br></div></div><div>If you declare it, use it, and then add dll attributes, we turn it into an error:</div><div><div>$ cat t.c</div><div>void Sleep(unsigned long MS);</div><div>void f() { Sleep(0); }</div><div>void __declspec(dllimport) Sleep(unsigned long MS);</div><div>$ clang -c t.c</div><div>t.c:3:28: error: redeclaration of 'Sleep' cannot add 'dllimport' attribute</div></div><div><br></div><div>We decided on this behavior because dllimport-ness affects how the symbol can be used in constant expressions. For example, this needs dynamic initialization:</div><div>int __declspec(dllimport) foo;</div><div>int *p = &foo;</div><div><br></div><div>This does not:</div><div><div>int foo;</div><div>int *p = &foo;</div></div><div><br></div><div>If you declare foo without dllimport and than add it after we've emitted the initializer for p, that's a miscompile, so we won't let you do it.</div><div><br></div><div>It also feeds into things like constexpr.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 5, 2015 at 10:03 AM, Edward Diener <span dir="ltr"><<a href="mailto:eldlistmailingz@tropicsoft.com" target="_blank">eldlistmailingz@tropicsoft.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Testing some Boost libraries with the latest build of clang I get the failure:<br>
<br>
c:/mingw/i686-w64-mingw32/include\synchapi.h:127:26: error: redeclaration of 'Sleep' cannot add 'dllimport' attribute<br>
  WINBASEAPI VOID WINAPI Sleep (DWORD dwMilliseconds);<br>
                         ^<br>
..\..\..\boost/smart_ptr/detail/yield_k.hpp:63:29: note: previous declaration is here<br>
  extern "C" void __stdcall Sleep( unsigned long ms );<br>
                            ^<br>
1 error generated.<br>
<br>
Has clang now changed so that a redeclaration with or without a 'dllimport' attribute is now an error ?<br>
<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div>