How would I implement something similar to the Objective-C @encode() compiler directive in ANSI C?
The @encode directive returns a const char * which is a coded type descriptor of the various elements of the datatype that was passed in. Example follows: struct test { int ti ; char tc ; } ; printf( "%s", @encode(struct test) ) ; // returns "{test=ic}" I could see using sizeof() to determine primitive types - and if it was a full object, I could use the class methods to do introspection. However, How does it determine each element of an opaque struct? @Lothars answer might be "cynical", but it's pretty close to the mark, unfortunately. In order to implement something like @encode() , you need