构建Kotlin本机示例应用程序时,获取大量SDL“推断类型为x但预期为Ux”

时间:2018-08-29 10:21:10

标签: kotlin sdl windows64 kotlin-native

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())

将转换从.toInt()转换为.toUInt()可以解决特定问题,但随后我遇到了更多问题:

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())

为什么会这样?这与我构建kotlin-native来针对当前平台(即64位Windows 7(带有./gradlew dist distPlatformLibs)的事实有关

0 个答案:

没有答案