webarkit / jsartoolkitNFT

jsartolkitNFT is a smaller version of jsartoolkit5 with only NFT support
GNU Lesser General Public License v3.0
132 stars 25 forks source link

ARToolKitJS.cpp:718:16: warning: ISO C++11 does not allow conversion from string literal to 'char *' ^ #129

Closed kalwalt closed 2 years ago

kalwalt commented 2 years ago

While building libs with emscripten i get warning like this one:

// long list of warnings, omitted for brevity.
ARToolKitJS.cpp:718:16: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
                webarkitLOGi("Allocated videoFrameSize %d", arc->videoFrameSize);
                             ^

Of course this is a WebARKitLib issue, writing here for future reference and as reminder.

kalwalt commented 2 years ago

this can be solved making these changes, example this code:

void webarkitLOGi(char* message) {
    EM_ASM ({
        var message = UTF8ToString($0);
        var infoHead =  UTF8ToString($1);
        var style = UTF8ToString($2);
        console.log(infoHead + message, style);
    },
    message,
    WARKTinfo,
    WARKTinfoStyle
    );
}

became:

void webarkitLOGi(const std::string &message) {
    EM_ASM ({
        var message = UTF8ToString($0);
        var infoHead =  UTF8ToString($1);
        var style = UTF8ToString($2);
        console.log(infoHead + message, style);
    },
    message.c_str(),
    WARKTinfo,
    WARKTinfoStyle
    );
}

This should be done in all the methods.

kalwalt commented 2 years ago

This is fixed in branch https://github.com/webarkit/WebARKitLib/tree/fix-webarkitLog