Coder Social home page Coder Social logo

Comments (11)

sbc100 avatar sbc100 commented on May 31, 2024

Are you trying to use val.h under gcc? In general I would assume that emscripten headers are only compatible with the version of clang that we support.

from emscripten.

sparlist avatar sparlist commented on May 31, 2024

This fails when using clang compiler as well.

Compiler:-

Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: x86_64-apple-darwin23.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Error:-

/Users/xxxxx/tmp/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/val.h:239:20: error: assigning to 'void *' from 'const char *' discards qualifiers
239 | cursor->w[0].p = wt;
| ^~

from emscripten.

sbc100 avatar sbc100 commented on May 31, 2024

Hmm.. I wonder why we don't see that in emscripten.. since we use clang. Perhaps because its a system header and the rules are more lax?

Did you run into this while trying to use val.h outside of the context of emscripten?

from emscripten.

sbc100 avatar sbc100 commented on May 31, 2024

Can you share the exact command line you used to get that error using clang? I can't seem to reproduce it.

from emscripten.

sparlist avatar sparlist commented on May 31, 2024

Build Script:-

#!/bin/sh

# Set the local build directory
build=".wasm"

# Make the directory; generate the makefiles; make & install
mkdir -p $build && cd $build && \
emcmake cmake .. > /dev/null 2>&1

# If the cmake failed, try once more with a clean build directory clean
if [ $? != 0 ]; then
    cd .. && rm -rf $build && \
    mkdir -p $build && cd $build && \
    emcmake cmake ..
fi

# Now make
emmake make -j4 all

CMakeLists.txt:-


cmake_minimum_required(VERSION 3.20)
project(XXXXX-WASM CXX)

set (CMAKE_CXX_STANDARD 17)

set(SOURCES
    xxxxx.cpp
    ....
    yyyyy.cpp
)

set(LIBNAME xxxxx)

add_compile_options(-O3 -fPIC)

add_executable(${LIBNAME} ${SOURCES})

set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS "-Os -s DEMANGLE_SUPPORT=1 -s ALLOW_MEMORY_GROWTH=1 --bind")

from emscripten.

sbc100 avatar sbc100 commented on May 31, 2024

So does the warning show up when using emcc ? i.e. when you do emmake make?

from emscripten.

sbc100 avatar sbc100 commented on May 31, 2024

Oh I see, I probably have to instantiate the writeGenericWireType template in some way. Perhaps that is what I'm missing? How do you using embind in order to get the warning to trigger?

from emscripten.

sparlist avatar sparlist commented on May 31, 2024

yes - it fails at the 'emmake make -j4 all' stage

from emscripten.

sbc100 avatar sbc100 commented on May 31, 2024

@brendandahl do you think you know how to write a repro for this one?

from emscripten.

sparlist avatar sparlist commented on May 31, 2024

Here's the full error context:-


/Users/xxxxx/tmp/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/val.h:239:20: error: assigning to 'void *' from 'const char *' discards qualifiers
  239 |   cursor->w[0].p = wt;
      |                    ^~
/Users/xxxxx/tmp/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/val.h:261:3: note: in instantiation of function template specialization 'emscripten::internal::writeGenericWireType<const char>' requested here
  261 |   writeGenericWireType(cursor, BindingType<First>::toWireType(std::forward<First>(first)));
      |   ^
/Users/xxxxx/tmp/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/val.h:269:5: note: in instantiation of function template specialization 'emscripten::internal::writeGenericWireTypes<const char *&>' requested here
  269 |     writeGenericWireTypes(cursor, std::forward<Args>(args)...);
      |     ^
/Users/xxxxx/tmp/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/val.h:640:27: note: in instantiation of member function 'emscripten::internal::WireTypePack<const char *&>::WireTypePack' requested here
  640 |     WireTypePack<Args...> argv(std::forward<Args>(args)...);
      |                           ^
/Users/xxxxx/tmp/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/val.h:517:12: note: in instantiation of function template specialization 'emscripten::val::internalCall<emscripten::internal::EM_METHOD_CALLER_KIND::FUNCTION, bool, (lambda at /Users/xxxxx/tmp/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/val.h:518:7), const char *&>' requested here
  517 |     return internalCall<EM_METHOD_CALLER_KIND::FUNCTION, ReturnValue>(
      |            ^
/Users/xxxxx/tmp/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:1246:24: note: in instantiation of function template specialization 'emscripten::val::call<bool, const char *&>' requested here
 1246 |         return wrapped.call<ReturnType>(name, std::forward<Args>(args)...);
      |                        ^
/Users/xxxxx/yyyyy/zzzzz.cpp:19:59: note: in instantiation of function template specialization 'emscripten::wrapper<xxx:YYYYYY>::call<bool, const char *&>' requested here
   19 |     virtual bool WantXXXXX(const char* name) { return call<bool>("wantXXXXX", name); }

from emscripten.

brendandahl avatar brendandahl commented on May 31, 2024

val.call doesn't accept const char* as arguments. Use either val("some str") or std::string.

from emscripten.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.