#include <stdio.h>

struct obj_s {
	unsigned char a;
	int b;
	const char *c;
};

int checkByMode(struct obj_s *self, const char *message) {
	return printf("%p: %s\n", self, message);
}

#define OBJ_GETTER(member, type) \
	type get_##member(struct obj_s *self) { \
		int error_code = checkByMode(self, "common_get_"#member); \
		return (error_code < 0) ? (type)error_code : self->member; \
	}

OBJ_GETTER(a, unsigned char);
OBJ_GETTER(b, int);
OBJ_GETTER(c, const char *);

int main(void) {
	struct obj_s obj = {
		.a = 0xff,
		.b = 5566,
		.c = "Hello, world!"
	};
	printf("a:%x b:%d c:%s\n", get_a(&obj), get_b(&obj), get_c(&obj));
	return 0;
}
