nim-lang / 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.
MIT License
502 stars 62 forks source link

Computer freeze: c2nim on Linux, translating AnsiC header file #237

Closed heysokam closed 3 months ago

heysokam commented 2 years ago

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 time passes, memory continues filling up until the computer completely freezes and becomes non-responsive.

the-argus commented 1 year ago

Exact same issue for me in my ODE bindings repo. It's much easier to reproduce sokam's example because its smaller, but if you have nix installed then you can clone my repo at commit ea461f267b28b3e5bf5ed236b5855dc18c59e766 and just run nix build to see the bug.

the-argus commented 1 year ago

In @heysokam 's case, it is caused by line 42, as a result of (it seems) the two underscores in __stdcall. Also, you can fix the issue by removing line 56, for some reason. Or by moving it before the __stdcall. I have no clue what's going on here but I would really appreciate a fix because I can't get my ODE bindings until it is fixed :(

melMass commented 3 months ago

@the-argus Have you ever found a solution? I have 128gb of RAM, nothing else opened but I still OOM... I just discovered Futhark that looks nice too but would rather use c2nim

edit: for what it's worth, this is what I'm generating bindings for: https://github.com/ufbx/ufbx

heysokam commented 3 months ago

@the-argus Have you ever found a solution? I have 128gb of RAM, nothing else opened but I still OOM... I just discovered Futhark that looks nice too but would rather use c2nim

@melMass If your usecase is making bindings, futhark is ten million years ahead of c2nim, to the point of making this lib obsolete. The only real usecase of c2nim at the moment is translating C to Nim directly. It wasn't its original usecase, but its the only usecase that its still good for, when comparing with the power of clang+futhark Clang is a real C compiler after all, maintained by hundreds of people and used in production daily.

melMass commented 3 months ago

Thanks that's helpful! I guess I was ready for both (full nim rewrite, or just bindings) I will first push futhark then! Appreciated!

Araq commented 3 months ago

It wasn't its original usecase, but its the only usecase that its still good for, when comparing with the power of clang+futhark

So does futhark support C++ now? c2nim does, that would be another use case in its favor.

Araq commented 3 months ago

I have no clue what's going on here but I would really appreciate a fix because I can't get my ODE bindings until it is fixed

Use more #def annotations and read c2nim's manual.

heysokam commented 3 months ago

@Araq The problem is not fixed, but you do you