You can simulate namespaces in C as follows:
#include <stdio.h>
#include <math.h>
struct math_namespace {
double (*sin)(double);
};
const struct math_namespace math = {sin};
int main() {
printf("%f\n", math.sin(3));
return 0;
}
Are there any flaws in this, or just a situation where the prefix makes more sense? It just seems that doing it so clean.
Overv source
share