emscripten和C ++20

问题描述 投票:0回答:2

看起来Emscripten不支持C ++20

我尝试编译以下内容:

#include <stdio.h>

#include <span>

using std::span;

int main() {
  int a[2] = {1, 3};

  printf("hello, world!\n");
  return 0;
}

命令:

~/emsdk/upstream/emscripten/em++ ~/Documents/helloWord.cpp
我明白了:

error: no member named 'span' in namespace 'std' using std::span; ~~~~~^ 1 error generated. em++: error: '/Users/user/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -DEMSCRIPTEN -I/Users/user/emsdk/upstream/emscripten/cache/sysroot/include/SDL --sysroot=/Users/user/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/compat /Users/user/Documents/helloWordl.cpp -c -o /var/folders/v4/krr003h50x3_bfpnlpytbdjr0000gn/T/emscripten_temp_n8xk089h/helloWordl_0.o' failed (returned 1)
我可以使用Emscripten使用C ++ 20个功能(尤其是STD :: SPAN)。

在这里是版本的详细信息:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.26 (8eaf19f1c6a9a1b0cd0f9a91657366829e34ae5c) clang version 16.0.0 (https://github.com/llvm/llvm-project f81f0cb75a2808a67d2662f044ad07628fc9d900) Target: wasm32-unknown-emscripten Thread model: posix InstalledDir: /Users/user/emsdk/upstream/bin

	
c++ c++20 webassembly emscripten std-span
2个回答
3
投票
CREDIT:@SomeProgrammerDude @Marcglisse

添加标志-STD = C ++ 23也有效,截至2025年2月,运行后:

0
投票
# Fetch the latest version of the emsdk (not needed the first time you clone) git pull # Download and install the latest SDK tools. ./emsdk install latest # Make the "latest" SDK "active" for the current user. (writes .emscripten file) ./emsdk activate latest # Activate PATH and other environment variables in the current terminal source ./emsdk_env.sh


最新问题
© www.soinside.com 2019 - 2025. All rights reserved.