Getting lots of SDL 'inferred type is x but Ux

2019-08-17 08:34发布

问题:

L:\develop\kotlin-native\samples\tetris>call cinterop -def 
".\src\main\c_interop\sdl.def" -compilerOpts "-I\MSYS2\mingw64\include\SDL2" -target "mingw" -o sdl
 || exit /b
src\main\kotlin\SDL_Visualizer.kt:26:15: error: type mismatch: inferred type is Int but Uint32 /* = UInt */ was expected
    SDL_Delay(millis)
              ^
src\main\kotlin\SDL_Visualizer.kt:399:57: error: type mismatch: inferred type is Byte but Uint8 /* = UByte */ was expected
        SDL_SetRenderDrawColor(renderer, 127, 127, 127, SDL_ALPHA_OPAQUE.toByte())
                                                        ^
src\main\kotlin\SDL_Visualizer.kt:405:51: error: type mismatch: inferred type is Byte but Uint8 /* = UByte */ was expected
        SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE.toByte())
                                                  ^
src\main\kotlin\Tetris.kt:275:15: error: type mismatch: inferred type is Int but UInt was expected
        srand(time(null).toInt())

switching the conversion from .toInt() to .toUInt() fixes that particular one but then I run into more:

L:\develop\kotlin-native\samples\tetris>call cinterop -def 
".\src\main\c_interop\sdl.def" -compilerOpts "-I\MSYS2\mingw64\include\SDL2" -target "mingw" -o sdl
 || exit /b
src\main\kotlin\SDL_Visualizer.kt:26:15: error: type mismatch: inferred type is Int but Uint32 /* = UInt */ was expected
    SDL_Delay(millis)
              ^
src\main\kotlin\SDL_Visualizer.kt:399:57: error: type mismatch: inferred type is Byte but Uint8 /* = UByte */ was expected
        SDL_SetRenderDrawColor(renderer, 127, 127, 127, SDL_ALPHA_OPAQUE.toByte())
                                                        ^
src\main\kotlin\SDL_Visualizer.kt:405:51: error: type mismatch: inferred type is Byte but Uint8 /* = UByte */ was expected
        SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE.toByte())

Why would this be happening? Is it anything to do with the fact I built kotlin-native to target the current platform which is 64-bit Windows 7 ( with ./gradlew dist distPlatformLibs)