A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/bytedeco/javacpp/issues/379 below:

cast from ‘char*’ to ‘char’ loses precision · Issue #379 · bytedeco/javacpp · GitHub

file test.h:

class String {
public:
    String(const char *text, int length);

    operator char *();

    operator const char *();

private:
    char *data;
};

String::operator char *() {
    return data;
}

String::operator const char *() {
    return data;
}

String::String(const char *text, int length) {
    data = const_cast<char *>(text);
}

preset class Test.java:

@Properties(
        value = {
                @Platform(
                        include = {
                                "test.h",
                        }
                ),
        }
)
public class Test implements InfoMapper {
    @Override
    public void map(InfoMap infoMap) {
    }
}

Compilation of this example fails with error:

[INFO] g++ -I/path.../include/ -I/usr/lib/jvm/java-11-openjdk/include -I/usr/lib/jvm/java-11-openjdk/include/linux /path.../jniString.cpp /path.../jnijavacpp.cpp -march=x86-64 -m64 -O3 -s -Wl,-rpath,$ORIGIN/ -Wl,-z,noexecstack -Wl,-Bsymbolic -Wall -fPIC -pthread -shared -o libjniString.so -L/path.../lib/ -Wl,-rpath,/path.../lib/ 
/path.../jniString.cpp: In function ‘void Java_org_bytedeco_baumer_String_allocate__Lorg_bytedeco_baumer_String_2I(JNIEnv*, jobject, jobject, jint)’:
/path.../jniString.cpp:469:45: error: no matching function for call to ‘String::String(String*&, jint&)’
  469 |         String* rptr = new String(ptr0, arg1);
      |                                             ^
In file included from /path.../jniString.cpp:92:
/path.../include/test.h:22:1: note: candidate: ‘String::String(const char*, int)’
   22 | String::String(const char *text, int length) {
      | ^~~~~~
/path.../include/test.h:22:28: note:   no known conversion for argument 1 from ‘String*’ to ‘const char*’
   22 | String::String(const char *text, int length) {
      |                ~~~~~~~~~~~~^~~~
/path.../include/test.h:2:7: note: candidate: ‘constexpr String::String(const String&)’
    2 | class String {
      |       ^~~~~~
/path.../include/test.h:2:7: note:   candidate expects 1 argument, 2 provided
/path.../include/test.h:2:7: note: candidate: ‘constexpr String::String(String&&)’
/path.../include/test.h:2:7: note:   candidate expects 1 argument, 2 provided
/path.../jniString.cpp: In function ‘_jobject* Java_org_bytedeco_baumer_String_asBytePointer(JNIEnv*, jobject)’:
/path.../jniString.cpp:492:42: error: cast from ‘char*’ to ‘char’ loses precision [-fpermissive]
  492 |         rptr = (char)ptr->operator char*();
      |                                          ^
/path.../jniString.cpp:493:21: warning: NULL used in arithmetic [-Wpointer-arith]
  493 |         if (rptr != NULL) {
      |                     ^~~~

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4