Skip to content

Bindings to std::function produce poor error messages #1279

Open
@mukunth1987

Description

@mukunth1987

I am trying to call c++ function which takes std::function as argument. But std::function is being interpreted as std::array

Below is my code.

test.h

#include "cxx.h"
#include <functional> 

class A {
  public:
     A() {}
     using RespHandler = std::function<void(int val)>;
     void sendRequest(RespHandler handler) {
          // handler(100);
     }
}

main.rs

use autocxx::prelude::*; 

include_cpp! {
    #include "test.h"
    safety!(unsafe)
    generate!("A")
} 

fn main() {
}

Cargo build error:

gen0.cxx: error: cannot convert 'void (A::*) (A::RespHandler)' {aka 'void (A::*) (std::function<void(int)>)'} to 'void (A::*) (std::array<long unsigned int, 4>)' in initialization

Specifications

autocxx = "0.25.0"
cxx = "1.0.94"

Could you please help if i miss something ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions