Skip to content

Instantly share code, notes, and snippets.

Pierre Habouzit MadCoder

  • Apple
  • San Jose, CA
Block or report user

Report or block MadCoder

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View horrible-c-scope-abuse.c
#include <stdio.h>
#include <stdlib.h>
void (^block)(void);
if (rand() % 2) {
block = ^{ printf("odd\n"); };
} else {
View force_unused_result_error.c
id my_func(int a, int b, int c);
#define my_func(a, b, c) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic error \"-Wunused-result\"") \
my_func(a, b, c) \
_Pragma("clang diagnostic pop")
View failable-init.m
@implementation MyClass
+ (instancetype)sharedInstanceWithError:(NSError **)error
static _Atomic(MyClass *) sMyClass;
MyClass *tmp = nil, *expected = nil;
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__arm64__)
// this assumes that this platform has consume ordering
// for loads through dereferencing pointers, which both intel & arm have.
View is_even.c
bool is_even(unsigned n)
char buf[11];
sprintf(buf, "%10u", n);
switch (buf[9]) {
case '0': return true;
case '1': return false;
default: return is_even(buf[9]);
You can’t perform that action at this time.