Advertisement
Guest User

nim-typeImportC-template

a guest
Apr 6th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.56 KB | None | 0 0
  1. template typeImportC*(typeName: untyped, importC: string, header: string, baseType: typed, actions: untyped): typed =
  2.   when defined(useWinSdk):
  3.     type
  4.       typeName {.importC: importC, header: header.} = baseType
  5.         actions
  6.   else:
  7.     type
  8.       typeName = baseType
  9.         actions
  10.  
  11. typeImportC(SecHandle*, "SecHandle", "<Security.h>", object):
  12.   dwLower*: uint
  13.   dwUpper*: uint
  14.  
  15. # Should Produce
  16. when defined(useWinSdk):
  17.   type
  18.     SecHandle* {.importC: "SecHandle", header: "<Security.h>".} = object
  19.       dwLower*: uint
  20.       dwUpper*: uint
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement