是否可以通过编译器指令检测代码中的 WASM 编译器?

发布于 2025-01-15 10:39:33 字数 233 浏览 0 评论 0原文

我是否可以在自己的 C++ 代码中检测到一个标准的 #define 来指示 WASM 是否正在编译代码?

在 Android 上的 C++ 中,我可以使用 #ifdef __ANDROID__ 但我不确定 Web Assembly 是否适用?我实际上使用的是 emcc 编译器,所以也许 EMCC 编译器有一个标准的 #define ...

谢谢

Is there a standard #define I can detect within my own C++ code that would indicate if WASM is compiling the code?

In C++ on Android I can use #ifdef __ANDROID__ but I'm not sure for Web Assembly ? I'm actually using emcc compiler so maybe there's a standard #define for EMCC compiler...

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以酷 2025-01-22 10:39:33

您可以使用 __wasm__ 来检测一般的 Wasm 架构,或者使用 __wasm32__/__wasm64__ 来更精确地检测。或者您可以使用 __EMSCRIPTEN__ 来专门检测 emscripten 目标。

You can use __wasm__ to detect the Wasm architecture in general or __wasm32__/__wasm64__ to be more precise. Or you can use __EMSCRIPTEN__ to specifically detect the emscripten target.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文