• addie
    link
    fedilink
    arrow-up
    7
    ·
    5 days ago

    To be fair, compiling C code with a C++ compiler gets you all the warnings from C++'s strong-typing rules. That’s a big bonus for me, even if it only highlights the areas of your C that are likely to become a maintenance hazard - all those void* casts want some documentation about what assumptions make them safe. Clang will compile variable-length arrays in C++, so you might want to switch off that warning since you’ve probably intended it. Just means that you can’t use designated initialisers, since C++ uses constructors for that and there’s no C equivalent. I’d be happy describing code that compiles in either situation as “C+”.

    Also stops anyone using auto, constexpr or nullptr as variable names, which will help if you want to copy-paste some well-tested code into a different project later.