I am trying to map a number to a keyword type in C. Is there anyway to do this?
#include <stdio.h>
#include <stdlib.h>
#include "memory.h"
#define DOUBLE_TYPE 1
#define INT_TYPE 2
#define OBJECT_TYPE(Y)
#if Y == DOUBLE_TYPE \
double \
#elif Y == INT_TYPE \
int \
#else \
int \
#endif \
int main(int argc, char* argv[]) {
unsigned int type = 1;
OBJECT_TYPE(type) value = 0.5f;
printf("%f\n", value);
return 0;
}
test.c:11:3: error: missing binary operator before token "double"
double \
I want to be able to cast a void* to a specific type known by the integer code.
defaulttype.