Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

c2nim

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.

Subscribe to updates I use c2nim


Statistics on c2nim

Number of watchers on Github 102
Number of open issues 45
Average time to close an issue 4 months
Main language Nimrod
Average time to merge a PR 5 days
Open pull requests 6+
Closed pull requests 4+
Last commit about 2 years ago
Repo Created almost 6 years ago
Repo Last Updated about 2 years ago
Size 326 KB
Homepage http://nim-lang.o...
Organization / Authornim-lang
Contributors14
Page Updated
Do you use c2nim? Leave a review!
View open issues (45)
View c2nim activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating c2nim for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

c2nim

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 after the translation process. c2nim is no real compiler!

Please see the manual here.

Installing

Install https://github.com/nim-lang/nimble#installation, clone this repository and run nimble build in your checkout.

Translating

c2nim is preliminary meant to translate C header files. Because of this, the preprocessor is part of the parser. For example:

  #define abc 123
  #define xyz 789

Is translated into:

  const
    abc* = 123
    xyz* = 789

c2nim is meant to translate fragments of C code and thus does not follow include files. c2nim cannot parse all of Ansi C and many constructs cannot be represented in Nim: for example duff's device cannot be translated to Nim.

c2nim open issues Ask a question     (View All Issues)
  • over 3 years Build failure: Unhandled expetion
  • over 3 years Interleaved enum and #define declarations Invalid
  • over 3 years Is this a valid pre-processor declaration?
  • almost 4 years Large numbers
  • almost 4 years c2nim doesn't like using macro to declare imported symbol
  • about 4 years c2nim docs: 404 Not Found
  • about 4 years c2nim not marking structs as {.pure.}
  • about 4 years typedef with struct is not properly generated.
  • about 4 years 'def X' doesn't work well when 'X' appears in a preprocessor directive
  • over 4 years CPP Operator pointers
  • over 4 years CPP function ptrs
  • over 4 years CPP #ifdef #endif within class definition
  • over 4 years ifndefs do not translate properly at all. Possibly a failed attempt to optimize out Include Once constructs
  • over 4 years Empty PP conditional branches produce wrong code
  • over 4 years Add translation-time calculated `#ifdef`'s
  • over 4 years c2nim fails on some typedefs
  • almost 5 years C enum and then constant array declaration with uncommon syntax fails
  • almost 5 years Wrong indentation produced for Macro containing do { } while()
  • almost 5 years preparser directives after if(){} fail
  • about 5 years unary defined operator
  • about 5 years Some types should be changed automatically
  • over 5 years Fails on `++`
c2nim open pull requests (View All Pulls)
  • Added staticlib option similar to dynlib.
  • Empty #define and reserve word defines
  • window-dressing
  • Added support for #skip directive
  • Fix issue caused by ifdef as last item in struct
  • Nested Types
c2nim list of languages used
Other projects in Nimrod