simonkrauter / NiGui

Cross-platform desktop GUI toolkit written in Nim
MIT License
718 stars 50 forks source link

Compilation Error on Windows #129

Closed KnorrFG closed 3 years ago

KnorrFG commented 3 years ago

Hey, I just updated nigui to version 0.2.5 and found a bug, tested on windows 10 with nim 1.4.2 This program compiles just fine with nim c main

main.nim

import nigui
import nigui / msgBox

app.init()

var 
    win = newWindow("test")
    exportButton = newButton("\u2611 Export")

win.add(exportButton)
exportButton.onClick = proc(ev: ClickEvent)=
    msgBox(win, "Test")

win.show()
app.run()

but when compiling with nim c --gc:arc main it will produce the following error: C:\Users\knorr\.nimble\pkgs\nigui-0.2.5\nigui\private\windows\platform_impl.nim(1564, 68) Error: expression cannot be cast to pointer

ghost commented 3 years ago

This is due to arc changing string representation (https://github.com/nim-lang/Nim/issues/13154). Winim fixed in in https://github.com/khchen/winim/commit/d300192c588f73dddef26e3c317f148aa23465c3, the relevant diff is at the bottom.

I wrote the code that's causing this and I'll try to take a look at it soon, possibly it can be fixed by just taking a pointer to the array instead of the string object itself (seems to be exported in lib/system/widestrs.nim).