8 ms·
Not directly related but does some c/c++ compiler implement a combination of flags that create a sort "c with templates" version of C ?
by Rexxar 3y ago
Not directly related but does some c/c++ compiler implement a combination of flags that create a sort "c with templates" version of C ?
- constantcrying 3y agoJust use C++ with just templates?
- jimbob45 3y agoThat would be my advice too. What was the point of “You don’t pay for what you don’t use” if nobody’s going to use it?
- SAI_Peregrinus 3y agoThere's no common C++ build system. That means (among other things) that there's no way to turn features you don't use into compile-time errors. There's no project configuration to select an allowed subset of features. All the difficulty goes onto the programmers, and in a multi-person project into the code review process. In practice, you end up using the combined set of C++ sublanguages each contributor chooses to use. You have to know about all of C++'s features to use C++ in a large enough team.
- pjmlp 3y agoYes there is, with tooling like Sonar.
- deleted 3y ago[deleted]
- cmovq 3y agoTemplates are so intertwined with the C++ type system such that bringing "just templates" to C would require also bringing in a bunch of C++ features if you want templates to behave like they do in C++. Just for starters, you would need name mangling and/or function overloading.
- LexiMax 3y agoIf C wanted a form of generics, it could likely do much better than templates. Concepts might've improved things, but I'm stuck on C++17 right now so I can't speak with experience.
- sigsev_251 3y agoCurrently it seems that the only possibility of getting generics in the language is generic lambdas wrapped in macros + tag compatible structs also wrapped in macros. It's fine but, skipping the preprocessor would be better.
- Gibbon1 3y agoI think it'd be more C like to add types as first class, tagged unions, and phat pointers.