GithubHelp home page GithubHelp logo

Comments (4)

Peefy avatar Peefy commented on September 21, 2024

Hello @AdmiralNemo. Thank you for your feedback. This may be due to Rust FFI type of core::ffi::c_char varies on different machines, and I will try using the generic fix later to address this issue. #983

from kcl.

Peefy avatar Peefy commented on September 21, 2024

Related Issue: kcl-lang/cli#31 and #985

from kcl.

AdmiralNemo avatar AdmiralNemo commented on September 21, 2024

Thanks for the quick response! With the latest commit, I'm seeing some different but related compilation errors:

error[E0308]: mismatched types
  --> runtime/src/context/api.rs:93:50
   |
93 |         p.set_kcl_location_info(None, Some(c2str(filename)), Some(line), Some(col));
   |                                            ----- ^^^^^^^^ expected `*const u8`, found `*const i8`
   |                                            |
   |                                            arguments to this function are incorrect
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`
note: function defined here
  --> runtime/src/api/utils.rs:40:15
   |
40 | pub(crate) fn c2str<'a>(s: *const c_char) -> &'a str {
   |               ^^^^^     ----------------

error[E0308]: mismatched types
   --> runtime/src/context/api.rs:107:33
    |
107 |         p.set_kcl_pkgpath(c2str(pkgpath));
    |                           ----- ^^^^^^^ expected `*const u8`, found `*const i8`
    |                           |
    |                           arguments to this function are incorrect
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`
note: function defined here
   --> runtime/src/api/utils.rs:40:15
    |
40  | pub(crate) fn c2str<'a>(s: *const c_char) -> &'a str {
    |               ^^^^^     ----------------

error[E0308]: mismatched types
   --> runtime/src/context/api.rs:119:36
    |
119 |         ctx.set_kcl_filename(c2str(filename));
    |                              ----- ^^^^^^^^ expected `*const u8`, found `*const i8`
    |                              |
    |                              arguments to this function are incorrect
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`
note: function defined here
   --> runtime/src/api/utils.rs:40:15
    |
40  | pub(crate) fn c2str<'a>(s: *const c_char) -> &'a str {
    |               ^^^^^     ----------------

error[E0308]: mismatched types
   --> runtime/src/context/api.rs:208:5
    |
193 | ) -> *const c_char {
    |      ------------- expected `*const u8` because of return type
...
208 |     result_json
    |     ^^^^^^^^^^^ expected `*const u8`, found `*const i8`
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`

error[E0308]: mismatched types
   --> runtime/src/value/api.rs:196:33
    |
196 |         if v.is_null() || *v == '\0' as i8 {
    |                                 ^^^^^^^^^^ expected `u8`, found `i8`

error[E0277]: can't compare `u8` with `i8`
   --> runtime/src/value/api.rs:196:30
    |
196 |         if v.is_null() || *v == '\0' as i8 {
    |                              ^^ no implementation for `u8 == i8`
    |
    = help: the trait `PartialEq<i8>` is not implemented for `u8`
    = help: the following other types implement trait `PartialEq<Rhs>`:
              <u8 as PartialEq<serde_json::Value>>
              <u8 as PartialEq>

error[E0308]: mismatched types
   --> runtime/src/value/api.rs:546:36
    |
543 | pub unsafe extern "C" fn kclvm_value_Str_ptr(p: *const kclvm_value_ref_t) -> *const kclvm_char_t {
    |                                                                              ------------------- expected `*const u8` because of return type
...
546 |         Value::str_value(ref v) => v.as_ptr() as *const i8,
    |                                    ^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`

error[E0308]: mismatched types
  --> runtime/src/stdlib/builtin_api.rs:17:35
   |
17 |     ctx.builtin_option_init(c2str(key), c2str(value));
   |                             ----- ^^^ expected `*const u8`, found `*const i8`
   |                             |
   |                             arguments to this function are incorrect
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`
note: function defined here
  --> runtime/src/api/utils.rs:40:15
   |
40 | pub(crate) fn c2str<'a>(s: *const c_char) -> &'a str {
   |               ^^^^^     ----------------

error[E0308]: mismatched types
  --> runtime/src/stdlib/builtin_api.rs:17:47
   |
17 |     ctx.builtin_option_init(c2str(key), c2str(value));
   |                                         ----- ^^^^^ expected `*const u8`, found `*const i8`
   |                                         |
   |                                         arguments to this function are incorrect
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`
note: function defined here
  --> runtime/src/api/utils.rs:40:15
   |
40 | pub(crate) fn c2str<'a>(s: *const c_char) -> &'a str {
   |               ^^^^^     ----------------

error[E0308]: mismatched types
  --> runtime/src/stdlib/plugin.rs:44:48
   |
44 |     let result_json = kclvm_plugin_invoke_json(method, args_json, kwargs_json);
   |                       ------------------------ ^^^^^^ expected `*const u8`, found `*const i8`
   |                       |
   |                       arguments to this function are incorrect
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`
note: function defined here
  --> runtime/src/stdlib/plugin.rs:66:19
   |
66 | pub extern "C" fn kclvm_plugin_invoke_json(
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^
67 |     method: *const c_char,
   |     ---------------------

error[E0308]: mismatched types
   --> runtime/src/_kcl_run.rs:190:34
    |
190 |             kclvm_value_Str(ctx, b"{}\0" as *const u8 as *const kclvm_char_t)
    |             ---------------      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
    |             |
    |             arguments to this function are incorrect
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`
note: function defined here
   --> runtime/src/value/api.rs:190:26
    |
190 | pub unsafe extern "C" fn kclvm_value_Str(
    |                          ^^^^^^^^^^^^^^^
191 |     ctx: *mut kclvm_context_t,
192 |     v: *const kclvm_char_t,
    |     ----------------------

error[E0308]: mismatched types
   --> runtime/src/_kcl_run.rs:203:39
    |
203 |             std::ptr::copy(c_str_ptr, result_buffer, return_len as usize);
    |             --------------            ^^^^^^^^^^^^^ expected `*mut u8`, found `*mut i8`
    |             |
    |             arguments to this function are incorrect
    |
    = note: expected raw pointer `*mut u8`
               found raw pointer `*mut i8`
note: function defined here
   --> /build/rustc-ZBSOmY/rustc-1.70.0+dfsg0ubuntu1~bpo2/library/core/src/intrinsics.rs:2710:21

from kcl.

Peefy avatar Peefy commented on September 21, 2024

@AdmiralNemo Sorry, see this PR: #986, it is merged. You can try it again. 🙏 Pls note the build deps. https://github.com/kcl-lang/kcl/blob/main/scripts/docker/kcl-builder-arm64/Dockerfile

from kcl.

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.