c2nim
c2nim copied to clipboard
c2nim is a tool to translate Ansi C code to Nim. The output is human-readable Nim code that is meant to be tweaked by hand before and after the translation process.
c2nim correctly identifies the size of integers appended with `LL` or similar, but fails to remove those suffixes in the generated code. Here is an example: ```c static inline double...
ref https://github.com/nim-lang/Nim/pull/19972 ``` 2022-07-28T11:12:09.4182108Z Downloading https://github.com/nim-lang/c2nim using git 2022-07-28T11:12:09.4182506Z Verifying dependencies for c2nim@#head 2022-07-28T11:12:09.4182810Z Installing c2nim@#head 2022-07-28T11:12:09.4183134Z Building c2nim/c2nim using c backend 2022-07-28T11:12:09.4183913Z [1m/tmp/nimble_20270/githubcom_nimlangc2nim_#head/c2nim.nim(12, 16) [0m[33mWarning: [0mNumber of spaces around...
C code that takes a callback is typically not equipped to deal with Nim exceptions: this means that function pointers, apart from being `cdecl` it must also be `raises: []`
Header: ```c extern const int xxx_symbol; ``` Command: ```bash $ c2nim --version 0.9.18 $ c2nim --header --importc --nep1 test.h ``` Output: ```nim let xxxSymbol* {.header: "test.h".}: cint ``` several problems...
```c typedef void (*some_proc)(const void *key); void xxx(some_proc p); ``` ```nim type SomeProc* = proc (key: pointer) {.cdecl.} proc xxx*(p: SomeProc) {.cdecl, importc: "xxx", header: "test.h".} ``` `importc` here is...
types like `uint64_t` and friends have direct correspondents in Nim (`uint64`) - this should be recognised and translated accordingly.
``` typedef struct { const br_sslrec_in_cbc_class *vtable; #ifndef BR_DOXYGEN_IGNORE uint64_t seq; union { const br_block_cbcdec_class *vtable; br_aes_gen_cbcdec_keys aes; br_des_gen_cbcdec_keys des; } bc; br_hmac_key_context mac; size_t mac_len; unsigned char iv[16]; int...
Example (from a header file): ```nim void wlr_render_rect(struct wlr_renderer *r, const struct wlr_box *box, const float color[static 4], const float projection[static 9]); ``` `Warning: token expected: ; but got: (...
System: Arch Linux Console application: Alacritty Shell: Bash c2nim Version: 0.9.18 Command executed: `c2nim vk_platform.h` File: https://github.com/JBustos22/oDFe/blob/master/code/renderercommon/vulkan/vk_platform.h Result: Console freezes after giving warnings about some comments being ignored. If enough...