Skip to content

Instantly share code, notes, and snippets.

@cocoatomo
Created May 14, 2011 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cocoatomo/972214 to your computer and use it in GitHub Desktop.
Save cocoatomo/972214 to your computer and use it in GitHub Desktop.
PyObject の基礎: ソースコード2
#include <stdio.h>
#include <stdlib.h>
struct base {
int basic_field;
};
struct extended {
struct base base;
int extended_field;
};
int main(void)
{
struct base *base_obj;
struct extended *obj = malloc(sizeof(struct extended));
obj->base.basic_field = 1;
obj->extended_field = 2;
base_obj = (struct base *) obj;
printf("base_obj->basic_field: %d\n", base_obj->basic_field);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment