2 ms·
It happens occasionally. An example would be that there are a couple of libraries that do "generic collections" in C using the preprocessor (instead of using te
by OskarS 6y ago
It happens occasionally. An example would be that there are a couple of libraries that do "generic collections" in C using the preprocessor (instead of using templates). So, you could imagine something like this:
#define VEC_TYPE double
#include <c-vector.h>
#undef VEC_TYPE
and that would provide you a type like "vec_double", a vector specialized for the double type. You'd want to import that once for each vector type you wanted.
It's not the most common use-case (and you can argue if it's a good idea at all), but it is at least a reasonable reason why you'd want a header file without #pragma once.
- glouwbug 6y agoYe, I pushed it to the extreme and back ported a good chunk of the STL to C: https://www.github.com/glouw/ctl https://www.github.com/glouw/ctl