Skip to content

Instantly share code, notes, and snippets.

View bolinfest's full-sized avatar

Michael Bolin bolinfest

  • Meta
View GitHub Profile
$ ./main.o example.c
Diagnostic count: 1
Diagnostic spelling: use of undeclared identifier 'retur'
Formatted diagnostic: example.c:5:3: error: use of undeclared identifier 'retur' [2, Semantic Issue]
No source ranges for diagnostic.
#include <stdio.h>
int main(int argc, char **argv) {
// Here is the syntax error:
retur 0;
}
@bolinfest
bolinfest / main.c
Created April 22, 2014 22:11
Dump source ranges for diagnostics using libclang.
#include <clang-c/Index.h>
#include <stdio.h>
void parseMalformedFile(char* source) {
CXIndex index = clang_createIndex(
/* excludeDeclarationsFromPCH */ 0,
/* displayDiagnostics */ 0);
const char *args[] = {
"-I/usr/include",
"-I.",
---- example.h ----
#import <Foundation/Foundation.h>
#ifndef __has_feature // Optional.
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
#endif
#ifndef NS_RETURNS_NOT_RETAINED
#if __has_feature(attribute_ns_returns_not_retained)
@bolinfest
bolinfest / docbook_to_html.py
Created October 28, 2013 16:51
This is the script that I used to convert Appendix B of Closure: The Definitive Guide from the DocBook XML from the Manuscript to HTML.
import cgi
import re
import xml.dom.minidom
# Omit trailing slash.
HOST = 'http://www.bolinfest.com'
STYLE = """
body {
width: 825px;