Skip to content

Instantly share code, notes, and snippets.

@nhasbun
Created June 10, 2019 20:06
Show Gist options
  • Save nhasbun/ae36faad9663a744ec9bbfee438e5627 to your computer and use it in GitHub Desktop.
Save nhasbun/ae36faad9663a744ec9bbfee438e5627 to your computer and use it in GitHub Desktop.
Collection of useful C macros
#define BIT(x,n) (((x) >> (n)) & 1)
#define INSERT_BITS(original, mask, value, num) (original & (~mask)) | (value << num)
#ifdef __ASSEMBLY__
#define CAST(type, value) value
#else
#define CAST(type, value) ((type)(value))
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment