@yglukhov, THANK YOU for nudging me into trying something!

If you look at the 
[pdcurses](https://github.com/lcrees/pdcurses/blob/master/pdcurses.nim), it has 
this code: 
    
    
    when defined(windows):
      ...
      const PDCURSED = "pdcurses.dll"
      
      {.pragma: stdcall.}
    else:
      ...
      
      {.pragma: cdecl.}
    

Doesn't this set the procedure calling convention for the rest of the file? In 
the above example I gave, I added the _cdecl_ in the **pragma** part of the 
procedure, but in the wrapper it's just: 
    
    
    proc wmove*(a2: ptr WINDOW; a3, a4: cint): cint {.importc: "wmove".}
    

So the abbreviated code looks like this: 
    
    
    {.deadCodeElim: on.}
    ...
    when defined(windows):
      ...
      const PDCURSED = "pdcurses.dll"
      
      {.pragma: stdcall.}
    else:
      ...
      
      {.pragma: cdecl.}
    
    # type declarations
    ...
    
    {.push dynlib: PDCURSED.}
    
    # procedure declarations
    ...
    proc wmove*(a2: ptr WINDOW; a3, a4: cint): cint {.importc: "wmove".}
    ...
    
    {.pop.}
    

Then I tried manually adding the _noconv_ to every procedure declaration: 
    
    
    proc wmove*(a2: ptr WINDOW; a3, a4: cint): cint {.noconv, importc: "wmove".}
    

AND IT WORKS! Funnily, it works with either _cdecl_, _stdcall_ or _noconv_?

Why? 

Reply via email to