Sergey Bugaev · @bugaevc
814 followers · 806 posts · Server floss.social

@amdg2 aha, right, good point about conditional includes! And the same defer mechanism would be just as useful for undefining macros. So, I imagine something like this:

// in stdlib.h

__cplusplus
<algorithm>


__cplusplus
<algorithm>

static inline void qsort(whatever) {
// Efficient implementation using std::sort
}

#define #include #defer #undef #uninclude #enddefer

Last updated 1 year ago

Sergey Bugaev · @bugaevc
814 followers · 806 posts · Server floss.social

@amdg2 cursed! The uninclude would happen at the end of the header file it's in, right?

Also I don't think the preprocessor ever uses the double hash sign syntax, how about this?


<foo>

#defer #uninclude #enddefer

Last updated 1 year ago

Sergey Bugaev · @bugaevc
814 followers · 775 posts · Server floss.social

Also, (or exclude?) to undo the effects of a previous include — undef preprocessor definitions, forget all the types & prototypes & stuff declared, as if nothing happened.

#uninclude

Last updated 1 year ago