[cfe-dev] size_t redefinition error with --target=wasm on Windows

Bill Ticehurst via cfe-dev cfe-dev at lists.llvm.org
Tue Apr 2 12:21:25 PDT 2019

Hi all,

Just joined this dl, so apologies if this is not the right place for such a question. Please redirect me if appropriate.

I’ve been trying to use the new --target=wasm option on Windows, with the minimal codebase from the repo at https://github.com/PetterS/clang-wasm (which targets Linux). Whether I use clang++ or clang-cl (with what I believe to be the right options) I get an error re the MSVC headers trying to redefine size_t, e.g. as shown below:

C:\temp\clang-wasm>"C:\Program Files\LLVM\bin\clang++.exe" -c --target=wasm32 -Os -flto -nostdlib -fvisibility=hidden -std=c++14   -ffunction-sections -fdata-sections -fms-extensions -fms-compatibility -fms-compatibility-version=19.16.27026   -I "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include"   -I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt"   -D _M_IX86 -o library.o library.cpp
In file included from library.cpp:1:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\memory.h:12:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_memory.h:13:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt.h:10:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\vcruntime.h:184:30: error: typedef redefinition with different types ('unsigned int' vs 'unsigned long')
    typedef unsigned int     size_t;

Any ideas on this? Being a new feature I can’t find too many docs or examples, so I may be messing up something simple.

Using clang-cl I get similar errors. (And need to set the include directories and architecture (-D _M_IX86) explicitly to avoid other errors – which I though clang-cl should set automatically when running from the Developer Command Prompt). Without --target=wasm with similar (but valid .exe) code, I don’t see any errors.

You can see my build commands/flags with comments in my fork at https://github.com/billti/clang-wasm/blob/master/build.bat (using a bat file to keep it simple at this point).


  *   Bill

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190402/51ddd7cf/attachment.html>

More information about the cfe-dev mailing list