Char data type in C/C++

arrays, c, c++, char, string

Solution

As Mysticial pointed out, these are multicharacter literals. Their type is implementation-dependent, but it's probably Java `long`, because they use 48 bits.

In Java, you need to convert them to `long` manually:

static long toMulticharConst(String s) {
    long res = 0;
    for (char c : s.toCharArray()) {
        res <<= 8;
        res |= ((long)c) & 0xFF;
    }
    return res;
}

final long a = toMulticharConst("102001");
final long b = toMulticharConst("102002");
final long c = toMulticharConst("202001");
final long d = toMulticharConst("202002");

Problem

I am trying to call a C++ DLL in Java. In its C++ head file, there are following lines: ``` #define a '102001' #define b '102002' #define c '202001' #define d '202002' ``` What kind of data type are for a, b, c, and d? are they char or char array? and what are the correpsonding data type in Java that I should convert to?

Original source

Related problems