@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
#define __cplusplus
#include <algorithm>
#defer
#undef __cplusplus
#uninclude <algorithm>
#enddefer
static inline void qsort(whatever) {
// Efficient implementation using std::sort
}
#define #include #defer #undef #uninclude #enddefer
@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?