Skip to content

Instantly share code, notes, and snippets.

@yppp
Created October 30, 2012 05:43
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 yppp/3978510 to your computer and use it in GitHub Desktop.
Save yppp/3978510 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define GET_FIRST(x) ((*(pack*) &x).first)
#define GET_SECOND(x) ((*(pack*) &x).second)
typedef struct pack_tag
{
unsigned short first;
unsigned short second;
} pack;
int main()
{
int x = 0;
for(x = 0; GET_FIRST(x) < 100; GET_FIRST(x)++)
{
GET_SECOND(x) += GET_FIRST(x) + 1;
printf("%d\n", GET_FIRST(x));
printf("%d\n", GET_SECOND(x));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment