@couven92 At first, I thought the easiest was to "give up" on Windows 7, but 
when I actually ran the test, the program compiled, but failled to link, with 
this message:
    
    
    atomiks.obj : error LNK2019: unresolved external symbol 
_InterlockedExchangeAddNoFence referenced in function 
atomicIncRelaxed_gujWN15RsV5Ef6kAMSLe8w
    

I'm assuming I'm declaring it correctly, otherwise it wouldn't even compile. 
But I have no clue how to deal with this error (Google was no help), so I gave 
up entirely on "NoFence". 

FYI, this is how I declare it, before using it:
    
    
    const
      hasThreadSupport = compileOption("threads") and not defined(nimscript)
    
    when declared(atomicLoadN):
      # USE PTHREADS!
      discard
    elif defined(vcc) and hasThreadSupport:
      when defined(cpp):
        # ...
        proc interlockedExchangeAddNoFence64(p: pointer; val: int64): int64
          {.importcpp: "_InterlockedExchangeAddNoFence64(static_cast<__int64 
volatile *>(#), #)", header: "<windows.h>".}
        proc interlockedExchangeAddNoFence32(p: pointer; val: int32): int32
          {.importcpp: "_InterlockedExchangeAddNoFence(static_cast<long 
volatile *>(#), #)", header: "<windows.h>".}
      else:
        # ...
        proc interlockedExchangeAddNoFence64(p: pointer, val: int64): int64
          {.importc: "_InterlockedExchangeAddNoFence64", header: "<windows.h>".}
        proc interlockedExchangeAddNoFence32(p: pointer, val: int32): int32
          {.importc: "_InterlockedExchangeAddNoFence", header: "<windows.h>".}
    

I Interpret this in the MS documentation:

> Header Winnt.h (include Windows.h)

As saying it's defined in winnt.h, but you should include Windows.h instead, 
which is what I did.

If it's a "compiler intrinsic", then why does the name still even exist at link 
time? Should it not have been replaced with the ASM code at compile time?

Reply via email to