@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?
Also, #uninclude (or exclude?) to undo the effects of a previous include — undef preprocessor definitions, forget all the types & prototypes & stuff declared, as if nothing happened.