Created
February 1, 2015 00:13
-
-
Save ghazel/c4970537e1b7456c9755 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <assert.h> | |
#include <inttypes.h> | |
struct hidden_data { | |
char * stuff; | |
uint8_t foo; | |
uint16_t bar; | |
uint32_t baz; | |
}; | |
#define _GEN_ACCESSOR(valname) \ | |
extern inline const typeof(((struct hidden_data *)0)->valname) \ | |
hidden_data_get_ ## valname(struct hidden_data * h) { \ | |
assert(h != NULL); \ | |
return h->valname; \ | |
} | |
_GEN_ACCESSOR(stuff) | |
_GEN_ACCESSOR(foo) | |
_GEN_ACCESSOR(bar) | |
_GEN_ACCESSOR(baz) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment