Elektrine lite

← Feed

@JamesWidman@mastodon.social

Post #2716220

2026-04-24 19:48 UTC

@TomF@mastodon.gamedev.place re translating C++ to C: this would have been pretty much trivial to do back in the days of Cfront. I think it may still even be possible with compilers that use the EDG front end...? (Or at least, if you get the front end directly from EDG, it has a C-generating back-end just like Cfront did.) But if you're using, say, Clang, you probably want to think in terms of LLVM IR, or possibly the new ClangIR (and its translation to LLVM IR).

Replies (2)

  • @JamesWidman@mastodon.social @TomF@mastodon.gamedev.place IMO having a mental model of what vtables are (a pointer to a list of function pointers), where implicit allocation happens (and that heap allocations have real cost), that inlining functions is a thing and when it can (not) or is (un)likely to happen etc already gets you pretty far (see also https://mastodon.gamedev.place/@TomF/116461364931250271 ) even if you don't know how exactly the specific compiler might optimize further with its IR

    Open ##2716221

  • @TomF@mastodon.gamedev.place 2026-04-24 20:03

    @JamesWidman@mastodon.social I'm not referring to "how does a compiler work". I'm describing how a programmer should think about the code they're writing. Very few people know how how LLVM IR works, and having looked at plenty myself I still find it extremely hard to parse. Asking people to think about phi nodes in their daily coding does not seem useful.

    Open ##2716226