Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind error of getting a pointer property in class #21651

Open
DylanShang opened this issue Mar 29, 2024 · 0 comments
Open

Bind error of getting a pointer property in class #21651

DylanShang opened this issue Mar 29, 2024 · 0 comments
Assignees
Labels

Comments

@DylanShang
Copy link

version
3.1.57-git

main.cpp

#include <string>
using namespace emscripten;

class Database {
public:
    Database(std::string databasePath): databasePath{databasePath}{
        printf("Database init \n");
    }
    std::string databasePath;
};

class Connection {
public:
    Connection(Database* database) {
        printf("Connection init\n");
        this->database = database;
    }

    Database* database;
};


EMSCRIPTEN_BINDINGS(my_module) {
    class_<Database>("Database")
        .constructor<std::string>()
        .property("databasePath", &Database::databasePath);
    class_<Connection>("Connection")
        .constructor<Database*>()
        .property("database", &Connection::database);
}

Build command:
emcc main.cpp -o main.js --bind

Error information:

emcc main.cpp -o main.js --bind                                     
main.cpp:30:9: error: expected expression
   30 |         .property("database", &Connection::database);
      |         ^
1 error generated.

It can run well without .property("database", &Connection::database);
But don't know how to bind the pointer property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants