Skip to content

Instantly share code, notes, and snippets.

@threedaymonk
Forked from tenderlove/gccmock.rb
Last active December 14, 2015 06:29
Show Gist options
  • Save threedaymonk/5043381 to your computer and use it in GitHub Desktop.
Save threedaymonk/5043381 to your computer and use it in GitHub Desktop.
# gccmock - generate exploding link stubs from linker error messages
#
# Usage: gcc [files] 2>&1 | ruby gccmock.rb > [filename].c
LINK_SYMBOL = /"_([_a-z0-9]*)",/
puts "#include <assert.h>"
puts "#define EXPLODE(name) void name() { assert(!\"unexpected call\"); }"
puts *ARGF.read.scan(LINK_SYMBOL).map { |a| "EXPLODE(#{a[0]})" }.sort.uniq
@threedaymonk
Copy link
Author

This is actually longer than my previous version, but the $1 in grep doesn't feel very pure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment