Hi,

Your particular function could be expressed with a const reference.  That
is:

int testReference(const int& input) {
    int ret = input;
    return ret;
}

(To see why it doesn't support non-const references, ask what you would
expect embind to do when C++ modifies an argument passed to it from
JavaScript.)


On Tue, Nov 25, 2014 at 12:26 AM, raytrace <[email protected]> wrote:

> Hi I want to use embind to expose below function with reference as
> parameter, and build it using dmcc --bind flag,
>
> int testReference( int& input)
> {
>   int ret = input;
>   return ret;
> }
>
> EMSCRIPTEN_BINDINGS(my_module) {
>
>     function("testReference", &testReference);
> }
>
> however I am facing the below errors:
>
> */Users/swd/Emscripten/emsdk_portable/emscripten/1.25.0/system/include/emscripten/bind.h:316:25:
> **error: *
>
> *      non-const lvalue reference to type 'int' cannot bind to a temporary
> of type 'int'*
>
>                         internal::BindingType<Args>::fromWireType(args)...
>
> *                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
>
>
> Does Embind support functions with reference as parameter?
>
>
> Thanks,
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Chad Austin
Technical Director, IMVU
http://engineering.imvu.com <http://www.imvu.com/members/Chad/>
http://chadaustin.me

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to