Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\private\scrolwin.nim(6, 58) Error: cannot convert 3221225472 to clong #21

Open
jlp765 opened this issue Dec 20, 2020 · 11 comments
Open

Comments

@jlp765
Copy link

jlp765 commented Dec 20, 2020

Error: type mismatch: got but expected 'clong = int32'

On win10
Nim Compiler Version 1.4.2 [Windows: amd64]

Seems to be some problem with 64bit/32bit definition for clong, as it expects int32 but the value is an unsigned 0xC000000

@PMunch
Copy link
Owner

PMunch commented Dec 21, 2020

Good catch! This was something that was changed in Nim at some point (that hex literals can't be negative signed numbers). But it is curious that I haven't seen this issue myself on Linux. Is the clong defined differently between the two platforms?

@thomasguo
Copy link

I got the same problem. My env is as follow:

On win7
Nim Compiler Version 1.4.2 [Windows: amd64]

@PMunch
Copy link
Owner

PMunch commented Jan 1, 2021

Was this from just running one of the examples? Or do you have a small code snippet I can try to reproduce this with?

@thomasguo
Copy link

I just tested the examples of wxnim, which are in folder examples\purewx . And the wxWidgets version is 3.1.4

@PMunch
Copy link
Owner

PMunch commented Jan 4, 2021

Hmm, I haven't tested with the newer 3.1.4 branch, only the 3.0.5 version. Could you try that?

@xbello
Copy link

xbello commented Jan 8, 2021

I get the same error with this minimal example:

import wxnim / [wx, genui]

{.experimental.}

genui:
  mainFrame % Frame(title = "Title")

mainFrame.show()
runMainLoop()

Compiles in linux (wx 3.0.5, nim 1.4.2) using nim cpp minimal.nim, shows the expected empty window.

Fails crosscompiling using nim cpp --cpu:i386 --d:mingw32 minimal.nim with the above error

private/scrolwin.nim(6, 52) Error: 3221225472 can't be converted to clong

Fails compiling in Windows 10 (wx 3.1.4, nim 1.4.2) using nim cpp -d:"wxWidgetsPath:C\wxWidgets-3.1.4" minimal.nim

Installed wx-3.0.5 to get the same error.

@xbello
Copy link

xbello commented Jan 8, 2021

But it is curious that I haven't seen this issue myself on Linux. Is the clong defined differently between the two platforms?

So it seems:

https://github.com/nim-lang/Nim/blob/1d8b7aa07ca9989b80dd758d66c7f4ba7dc533f7/lib/system.nim#L1368

@PMunch
Copy link
Owner

PMunch commented Jan 8, 2021

Hmm, that is peculiar. The underlying issue is probably that recent-ish versions of Nim restricted the ways numbers could be converted between signed and unsigned types. I think changing line 6 of scrollwin.nim to wxScrolledWindowStyle* = cast[clong](wxHSCROLL or wxVSCROLL) should fix the issue.

@xbello
Copy link

xbello commented Jan 8, 2021

That get rid of the "can't be converted", but the compilation still fails:

g++.exe: error: /IC:\wx\3.0.5\lib\gcc_lib\mswu: Invalid argument

Error: execution of an external compiler program 'g++.exe -c -std=gnu++14 -funsigned-char  -w -fmax-errors=3 -fpermissive -mno-ms-bitfields -DWIN32_LEAN_AND_MEAN -D__WXMSW__ -I"C:\wx\3.0.5\include" /I"C:\wx\3.0.5\lib\gcc_lib\mswu"   -IC:\Users\xbello\AppData\Local\nim-1.4.2\lib -IC:\Users\xbello\source\minimal -o C:\Users\xbello\nimcache\minimal_d\stdlib_io.nim.cpp.o C:\Users\xbello\nimcache\minimal_d\stdlib_io.nim.cpp' failed with exit code: 1

g++.exe: error: /IC:\wx\3.0.5\lib\gcc_lib\mswu: Invalid argument

@PMunch
Copy link
Owner

PMunch commented Jan 8, 2021

I think that's a completely separate issue, probably caused by this https://github.com/PMunch/wxnim/blob/master/wxnim/wxCompile.nim#L67. Someone else implemented this, so I don't really have much to go on here. Maybe @fredrikhr could help out?

@fredrikhr
Copy link

Ooops. That's a copy-paste error that has been there a loooong time 😮

It seems that I just copied

{.passC: "/I\"" & (wxWidgetsLibPath / "mswu") & "\"".}
and forgot to adjust that VCC uses /I for include, but G++ does not.

The fix is to change /I in line 67 to the correct flag in G++ or Clang. I guess that would be -I instead, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants