[cfe-dev] x64 windows (MinGW) and "__declspec(dllimport)" emits a "unknown attribute warning"

Eli Friedman eli.friedman at gmail.com
Mon Jul 18 16:22:29 PDT 2011


On Fri, Jul 15, 2011 at 1:59 PM, Ruben Van Boxem
<vanboxem.ruben at gmail.com> wrote:
> Hi,
>
> This small piece of code:
>
>> int main() {}
>> __declspec(dllexport) void foo (int); void bar (void) { foo (0); }
>
> emits following warning when Clang is built for x86_64-w64-mingw32,
> but not when built for i686-w64-mingw32:
>
>> foo.c:3:12: warning: unknown attribute 'dllexport' ignored [-Wattributes]
>> __declspec(dllexport) void foo (int); void bar (void) { foo (0); }
>>            ^
>> <built-in>:128:38: note: expanded from:
>> #define __declspec(a) __attribute__((a))
>>                                      ^
>> 1 warning generated.
>
> Note that this code has an undefined reference, that's not the point.
>
> I tried looking through Clang's code where this warning is emitted,
> but can't find anything relevant. The code differentiating x86 and x64
> (or most likely just "forgetting" x64 mingw) is probably deeper in the
> code.
>
> Any help is appreciated.

Try lib/Sema/TargetAttributesSema.cpp.

-Eli




More information about the cfe-dev mailing list