Skip to content

Instantly share code, notes, and snippets.

@haldun
Created March 18, 2012 22:12
Show Gist options
  • Save haldun/2082879 to your computer and use it in GitHub Desktop.
Save haldun/2082879 to your computer and use it in GitHub Desktop.
flags in c with enum
#include <stdio.h>
typedef enum {
kShareViewTypeNone = 0,
kShareViewTypeFacebook = 1 << 0,
kShareViewTypeTwitter = 1 << 1,
kShareViewTypeAll = kShareViewTypeFacebook | kShareViewTypeTwitter
} ShareViewType;
int main (int argc, char const *argv[])
{
ShareViewType shareViewType = kShareViewTypeFacebook;
shareViewType |= kShareViewTypeTwitter;
if (shareViewType & kShareViewTypeTwitter) {
printf("twitterda paylas\n");
}
if (shareViewType & kShareViewTypeFacebook) {
printf("fasbukte paylas\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment