- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 emscripten 编译 C++ 类并公开绑定(bind)。我遇到了编译器错误。
#include <emscripten/bind.h>
#include <emscripten/emscripten.h>
using namespace emscripten;
class MyClass {
private:
int _year;
int _month;
int _day;
public:
MyClass() { }
MyClass(int year, int month, int day);
int getMonth();
void setMonth(int);
int getYear();
void setYear(int);
int getDay();
void setDay(int);
bool isLeapYear();
int daysInMonth();
void increment();
void decrement();
};
EMSCRIPTEN_BINDINGS(my_sample_class) {
class_<MyClass>("MyClass")
.constructor<>()
.constructor<int, int, int>()
.function("getMonth", &MyClass::getMonth)
.function("increment", &MyClass::increment)
.function("decrement", &MyClass::decrement)
.property("year",&MyClass::getYear, &MyClass::setYear )
//.property("month", &MyClass::getMonth, &MyClass::setMonth )
//.property("day",&MyClass::getDay, &MyClass::setDay )
;
}
编译器在构造函数或函数绑定(bind)方面没有问题。我遇到了属性绑定(bind)问题。我只有一个未注释的,以尽量减少我返回的错误(它们只是相同错误的重复,但针对不同的行)。这是我回来的错误。
In file included from MyDate.cpp:1:
In file included from ./MyDate.h:2:
emscripten/bind.h:1393:26: error: implicit instantiation of undefined template 'emscripten::internal::GetterPolicy<int (MyClass::*)()>'
auto gter = &GP::template get<ClassType>;
^
./MyDate.h:37:6: note: in instantiation of function template specialization 'emscripten::class_<MyClass, emscripten::internal::NoBaseClass>::property<int (MyClass::*)(), void (MyClass::*)(int)>' requested here
.property("year",&MyClass::getYear, &MyClass::setYear )
^
emscripten/bind.h:569:16: note: template is declared here
struct GetterPolicy;
^
emscripten/bind.h:1399:33: error: implicit instantiation of undefined template 'emscripten::internal::GetterPolicy<int (MyClass::*)()>'
TypeID<typename GP::ReturnType>::get(),
^
emscripten\1.38.21\system\include\emscripten/bind.h:569:16: note: template is declared here
struct GetterPolicy;
^
2 errors generated.
shared:ERROR: compiler frontend failed to generate LLVM bitcode, halting
我查阅了绑定(bind)示例,看来我使用的是正确的语法。有人知道我可能做错了什么吗?
最佳答案
找到问题了!
getter 函数必须标记为 const 以避免这些错误。前任: int getMonth() const;
关于c++ - emscripten 中的错误绑定(bind)属性和函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54015006/
我需要将什么添加到我的 CMakeLists.txt 文件中,以便下面的示例来自 here还能建吗? 我可以毫无问题地生成 WASM,但不知道要在我的 CMakeLists.txt 中添加什么以停止出
我很好奇 emscripten 是否可以在没有 libc 的情况下构建二进制文件。 如果我有 simple.c: int add1(int x) { return x + 1; } 而且我不想
我已经研究了一段时间,我似乎无法找到如何实现这一点。 有一个非常明确的标题 emscripten_get_canvas_size,它没有做我期望它做的事情。实际的 Emscripten Canvas
Emscripten 教程很好地解释了如何与 C 函数交互:https://github.com/kripken/emscripten/wiki/Interacting-with-code 但是你如何
我对 WebAssembly 非常感兴趣,但我感到沮丧的是,即使是用 C++ 编码并使用 Emscripten 编译的“Hello World”示例,也会在浏览器中加载总共 396KB。是什么赋予了?
game engine我用来运行我的 game在浏览器中运行 lua 并在我的游戏中使用正常的 fopen/write/fclose 保存文件。引擎C/C++代码通过emscripten编译为JS。让
当使用不带任何参数的 emscripten 编译 C++ 时,除了 webgl Canvas 之外,它还会生成一个带有控制台和 emscripten Logo 的 html 文件。 是否可以禁用 Lo
我在 emscripten 中有一个 hello world 代码。如果可能的话,我想用 visual studio code 调试它并设置断点和调试更容易。我尝试这样做,但我无法在断点处停止。我使用
我正在阅读这里的 emscripten 教程 - https://github.com/kripken/emscripten/wiki/Tutorial 到目前为止,我已经下载了源代码并安装了依赖项并
是否可以使用 Emscripten 优化构建/编译 Opus/libopus?我不确定这是否是 Emscripten 和 WebAssembly 的一般当前限制,或者是否存在确保解码器在 WebAss
在 Emscripten wiki ( Interacting with code ) 中,只有两种类型被列为要传递给 ccall 的可能返回类型。或 cwrap (“数字”和“字符串”)。如何包装/
如何使用 emcmake cmake 并传递 emscripten 命令行选项? C++/CMake 的新手,但在谷歌上找不到任何有用的东西。所以也许这个问题只是愚蠢的,在那种情况下我道歉。 我可以使
我是 opencv.js 的新手。我在构建 opencv.js 时遇到了一些问题我正在使用 Windows 10。我按照以下步骤设置 opencv.js https://docs.opencv.org
我无法在另一个 JavaScript 文件中调用 C 函数,它给出了错误“在运行时初始化之前调用”please refer to this link 我按照给定链接中的描述在 emscripten 中
我正在尝试使用 Emscripten 构建一个使用 ffmpeg 库到 WebAssembly 的小项目。在此之前,我通过将一些简单的程序从 C 转换为 Wasm 来进行尝试,它运行良好,但那时我没有
我正在尝试将线程与 Emscripten 一起使用,但我不明白它是如何工作的。我已经阅读了一些关于网络 worker 的文字,但我不确定是否理解。 当我查看“tests”文件夹时,I can see
我正在运行一个使用 emscripten 编译为 wasm 的 C 工具。该工具适用于非常大的文件。在 CLI 上正常运行此工具时,操作通常会流式传输结果并在返回足够的数据后提前终止程序。例如,您可能
Mono 有一个 LLVM编译器。无论如何可以将它与 Emscripten 一起使用吗? (将 C# 代码编译为 JavaScript)? 最佳答案 目前没有现成的方法可以做到这一点。这也许是可能的,
我通过以下步骤安装了 Emscripten: 1.) Download the emsdk-portable version for Linux/MacOSX http://kripken.githu
我是 Emscripten/javascript 的新手,如果我的情况已经得到解决,我提前道歉。我在 ionic3 中有一个应用程序,我想读取 c 中有 3 个位置的数组,这个位置有其他数组,在结构上
我是一名优秀的程序员,十分优秀!