#include <stdio.h>
#include <stdlib.h>
struct object {
int inArray;
union ID {
int index;
void * address;
} id;
};
struct object * make_single_object()
{
struct object * obj = malloc(sizeof(struct object));
if (obj) {
obj->inArray = 0;
obj->id.index = -1;
obj->id.address = obj;
return obj;
}
else
return NULL;
}
int main(int argc, char *argv[])
{
struct object * obj;
if ((obj = make_single_object()) != NULL) {
printf("object address: %p\n", obj->id.address);
free(obj->id.address);
}
return 0;
}