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
)的事实有关