Description
Hi,
I'm very new to autocxx. Apologies if my expectations are naive.
We are investigating whether it would be possible to use autocxx on an existing codebase that already uses the cc
crate to build some C++ code that interfaces with LLVM. Currently we use the regular Rust C FFI and linkage magic.
I spent hours today figuring out what the following error means when I try to call the function I've generated bindings for:
error[E0618]: expected function, found `__ykllvmwrap_irtrace_compile`
--> yktrace/src/lib.rs:221:13
|
221 | ykllvmwrap::__ykllvmwrap_irtrace_compile(
| _____________-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
222 | | func_names.as_ptr(),
223 | | bbs.as_ptr(),
224 | | trace_len,
... |
231 | | di_tmpname_c,
232 | | )
| |_____________- call expression requires function
Our codebase is a workspace. The crate ykllvmwrap
is where I'm trying to replace C FFI functions with C++ ones. yktrace
is the consuming crate in this instance.
At first I thought it was because I was doing a cross-crate call to a C++ function. Modified your demo code to have a workspace and do a cross-crate C++ call... It worked.
It was only when I read our code's generated docs that I stumbled on:
autocxx bindings couldn’t be generated: Names containing __ are reserved by C++ so not acceptable to cxx
yet the build of ykllvmwrap
was successful.
Wouldn't it have been better if the build of the ykllvmwrap
crate had failed at generation time, displaying that message? I did explicitly ask for that function to be generated:
include_cpp! {
#include "ykllvmwrap.h"
safety!(unsafe)
generate!("__ykllvmwrap_irtrace_compile")
}
pub use ffi::__ykllvmwrap_irtrace_compile;
Perhaps it would make sense to silently fail in scenarios where you are blanket generating bindings for an API...
(I'm going to bet there's a good technical reason that things are like this 😄 )
Thanks!