On Fri, Oct 05, 2018 at 09:12:09PM +0200, Ævar Arnfjörð Bjarmason wrote: > > I'm not wild about declaring functions inside macros, just because it > > makes tools like ctags like useful (but I have certainly been guilty of > > it myself). I'd also worry that taking "code" as a macro parameter might > > not scale (what happens if the code has a comma in it?) > > There's always the option of generating the C code as part of some build > step and carrying around a big C file with various type-safe functions > that only differ in the types they operate on. It can even be committed > to source control. > > That sucks in some ways for sure, but is a lot friendlier for grepping, > ctags etc. Yeah, in a lot of ways the C preprocessor is not great for larger-scale code generation. I was hoping we could get away without having the bodies of these functions as part of the generated bit, though. I think what René showed later in the thread is not too bad in that respect. > I've just barely resisted the urge to include that thread where we were > discussing making the code C++-compiler compatible in the References > header :) Yes. The main thing I would want out of using C++ is type-safe, efficient data structures. IIRC, early versions of C++ were implemented via code generation, and we're basically walking down that same road. I'm not sure where the right cutoff is, though. It's nice to pick up the solution somebody else produced, but requiring a C++ compiler to build Git is a pretty big step that I imagine will create a lot of new problems. (We're just now allowing C99 -- I don't even want to think about what kind of compiler issues we'll run into on antique systems trying to use C++). -Peff