Skip to content

Instantly share code, notes, and snippets.

@robrix
Created March 1, 2014 05:37
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robrix/9285742 to your computer and use it in GitHub Desktop.
Save robrix/9285742 to your computer and use it in GitHub Desktop.
__attribute__((format_arg(__NSString__, 2)))
NSString *ಠ_ಠ_message(const char *severity, const char *format) {
return [NSString stringWithFormat:@"%s: %s", severity, format];
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-nonliteral"
__attribute__((format(printf, 1, 2)))
void ಠ_ಠ_warning(const char *format, ...) {
va_list ಠ_ಠ;
va_start(ಠ_ಠ, format);
NSLogv(ಠ_ಠ_message("warning", format), ಠ_ಠ);
va_end(ಠ_ಠ);
}
__attribute__((format(printf, 1, 2)))
void ಠ_ಠ_error(const char *format, ...) {
va_list ಠ_ಠ;
va_start(ಠ_ಠ, format);
NSLogv(ಠ_ಠ_message("error", format), ಠ_ಠ);
va_end(ಠ_ಠ);
}
#pragma clang diagnostic pop
typedef struct {
void (*oO)(const char *, ...);
void (*_)(const char *, ...);
} const ಠ_ಠ_disapproval_t;
extern ಠ_ಠ_disapproval_t ಠ_ಠ;
ಠ_ಠ_disapproval_t ಠ_ಠ = {
.oO = ಠ_ಠ_warning,
._ = ಠ_ಠ_error
};
static inline void __ಠ_ಠ__ (bool O_o, bool x_x) {
if (O_o) ಠ_ಠ .oO( "Is this some kind of sick joke?" );
if (x_x) ಠ_ಠ ._( "I don’t want to live on this planet any more." );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment