lol Barkin up the wrong tree. After 28 years of programming, I guess I must 
have written my fair share of C, no? (As some unrelated trivia, Arturo was 
initially written completely in C).

The question had mainly to do with Nim and how it translates things to C. 
Because knowing how to write something in C is one thing, having to guess how 
something will be translated to C is totally different.

* * *

For anyone that might care, the update version:
    
    
    #=======================================
    # Compilation & Linking
    #=======================================
    
    {.passC: "-I" & parentDir(currentSourcePath()) .}
    {.compile("libclipboard/clipboard_common.c", "-I" & 
parentDir(currentSourcePath())).}
    
    when defined(linux) or defined(freebsd):
        {.compile("libclipboard/clipboard_x11.c", "-DLIBCLIPBOARD_BUILD_X11 
-pthread").}
        {.passL: "-pthread -lxcb".}
    elif defined(macosx):
        {.compile("libclipboard/clipboard_cocoa.c", "-x objective-c 
-DLIBCLIPBOARD_BUILD_COCOA -framework Foundation").}
    elif defined(windows):
        {.compile("libclipboard/clipboard_win32.c", 
"-DLIBCLIPBOARD_BUILD_WIN32").}
    
    #=======================================
    # Types
    #=======================================
    
    type
        ClipboardMode* {.size: sizeof(cint).} = enum
            LCB_CLIPBOARD = 0
            LCB_PRIMARY = 1
            LCB_SELECTION = 2
            LCB_SECONDARY = 3
            LCB_MODE_END = 4
        
        ClipboardStruct* {.importc:"clipboard_c", header: 
"libclipboard/libclipboard.h", pure.} = object
        ClipboardObj* = ptr ClipboardStruct
    
    #=======================================
    # Function prototypes
    #=======================================
    
    {.push header: "libclipboard/libclipboard.h", cdecl.}
    
    proc clipboard_new*(cb_opts: pointer): ClipboardObj {.importc.}
    proc clipboard_clear*(cb: ClipboardObj, mode: ClipboardMode) {.importc.}
    proc clipboard_free*(cb: ClipboardObj) {.importc.}
    proc clipboard_set_text*(cb: ClipboardObj, src: cstring) {.importc.}
    proc clipboard_text*(cb: ClipboardObj): cstring {.importc.}
    
    {.pop.}
    
    
    Run

Reply via email to