Hi guys,
System: Windows 10, Nim Compiler Version 0.18.1 [Windows: amd64], compiling with VC++ 2017
Anyone have the problem of the CC compilation stopping? I have a {.cdecl.} proc used as a callback from a C static library (iup). If I do not use any functions from the same static library inside the proc, the compilation completes without problems. But when I add certain function calls from the static library to the proc, the CC compilation stops and hangs (waited more than 4 mins, before interrupting it) there at random modules. The code annotated with the lines that cause a halt follows:
proc text_changed(arg: PtrIhandle): cint {.cdecl.} =
var text: string = textbox.getAttribute("VALUE") # <-- This call does not cause a halt.
if text.split(':').len() != 3:
textbox.setAttribute("VALUE", stored_text) # <-- This call does not cause a halt.
for s in text.split(':'):
try:
var value = parseInt(s)
if value < 0 or value > 59:
# textbox.setAttribute("VALUE", stored_text) # <-- UNCOMMENTING THIS HALTS THE CC COMPILATION!
break
except:
# textbox.setAttribute("VALUE", stored_text) # <-- UNCOMMENTING THIS HALTS THE CC COMPILATION!
break
# stored_text = textbox.getAttribute("VALUE") # <-- UNCOMMENTING THIS HALTS THE CC COMPILATION!
# Set the callback
textbox.setCallback("VALUECHANGED_CB", text_changed) # <-- WHEN COMMENTING THIS OUT, WHATEVER IS USED IN THE ABOVE PROC, THE COMPILATION ALWAYS SUCCEEDS!
textbox is a global textbox reference, setAttribute, getAttribute and setCallback are the functions from the static library.
Has anyone had this kind of issue?
I had this kind of issue yesterday, actually. If you compile the nim compiler in debug mode, you'll get more info.
./koch boot
# instead of
./koch boot -d:release
In my case, I was getting a reference to an object (in your case textbox), but I was not actually importing the module with the proper procs, which made the compiler confused. Can we see the full code?
@jyapayne It's the same iup library, which I only has slightly modified pragmas and I renamed the PIHandle to PtrIhandle, to be able to change between static and dynamic compilation. All declarations are otherwise identical to the official iup library.
Any ideas? Thanks
I am on Windows 10, using the official static libraries from sourceforge. So it also took a long time to compile on Linux?
I ran it again and have been waiting for over an hour and it still shows:
C:\...\shutdown_app_iup>nim c shutdown.nim
Hint: used config file 'C:\Nim\config\nim.cfg' [Conf]
Hint: used config file 'D:\VISTA_NAMIZJE\NIM\nim.cfg' [Conf]
Hint: used config file 'D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\shutdown.nim.cfg' [Conf]
Hint: system [Processing]
Hint: shutdown [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: math [Processing]
Hint: bitops [Processing]
Hint: algorithm [Processing]
Hint: times [Processing]
Hint: winlean [Processing]
Hint: dynlib [Processing]
Hint: ospaths [Processing]
Hint: osproc [Processing]
Hint: strtabs [Processing]
Hint: hashes [Processing]
Hint: streams [Processing]
Hint: cpuinfo [Processing]
Hint: strfmt [Processing]
Hint: macros [Processing]
Hint: unicode [Processing]
Hint: niup [Processing]
Hint: niup_low [Processing]
CC: shutdown
CC: niup
CC: niup_low
No, I mean I had to compile the iup libraries from source, because the ones provided were for Ubuntu 10.04 or something and I'm on Ubuntu 18.04.
Ah, sorry, I confused your thread for the other thread about iup that said they were running fine on Windows and had trouble on Linux. Sorry about that!
I see you've updated with the fact that it works for the dynamic libraries. Is there a reason you want to use static vs dynamic?
I'm afraid I can't help much more because it looks like you're having a Windows specific issue and I'm not running Windows :( I totally mixed up the threads in my mind which is my bad!
Try killing hanging cl compiler in task manager. It usually outputs some extra error message in command line when you do that and it can contain useful info. It can be cl bug or Nim has generated invalid C/C++ code.
I tend you get it time to time as well, but too infrequently to figure out the reason behind it.
@cdome Great suggestion!!! I tried killing cl.exe and got:
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup>nim c shutdown.nim
Hint: used config file 'C:\Nim\config\nim.cfg' [Conf]
Hint: used config file 'D:\VISTA_NAMIZJE\NIM\nim.cfg' [Conf]
Hint: used config file 'D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\shutdown.nim.cfg' [Conf]
Hint: system [Processing]
Hint: shutdown [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: math [Processing]
Hint: bitops [Processing]
Hint: algorithm [Processing]
Hint: times [Processing]
Hint: winlean [Processing]
Hint: dynlib [Processing]
Hint: ospaths [Processing]
Hint: osproc [Processing]
Hint: strtabs [Processing]
Hint: hashes [Processing]
Hint: streams [Processing]
Hint: cpuinfo [Processing]
Hint: strfmt [Processing]
Hint: macros [Processing]
Hint: unicode [Processing]
Hint: niup [Processing]
Hint: niup_low [Processing]
CC: shutdown
Error: execution of an external compiler program 'cl.exe /c --platform:amd64 /nologo /Z7 -DWIN32_LEAN_AND_MEAN /IC:\Nim\lib /ID:\VISTA_NAMIZJE\NIM\niup /FoD:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.obj D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c' failed with exit code: 1
cl : Command line warning D9002 : ignoring unknown option '--platform:amd64'
shutdown.c
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(521): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(534): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(606): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(617): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(633): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(657): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(746): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(748): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(799): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(829): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(868): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(870): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(878): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(880): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(985): warning C4133: '=': incompatible types - from 'Ihandle *' to 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(989): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(991): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(993): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(995): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(998): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(998): warning C4028: formal parameter 1 different from declaration
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(1000): warning C4133: '=': incompatible types - from 'Ihandle *' to 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *'
D:\VISTA_NAMIZJE\NIM\shutdown_app_iup\nimcache\shutdown.c(1002): warning C4133: 'function': incompatible types - from 'tyObject_Ihandle_CCL3RNa8TRAjjKSFTBKqag *' to 'Ihandle *'
So the fix is to change:
type
Ihandle = object
to this:
type
Ihandle {.header: "iup.h", importc: "Ihandle".} = object
and it works like a charm!
Need to somehow remember this thread the next time this happens. Thanks @cdome and @jyapayne !