Skip to content

Instantly share code, notes, and snippets.

@L3n41c
Created February 14, 2012 19:29
Show Gist options
  • Save L3n41c/1829475 to your computer and use it in GitHub Desktop.
Save L3n41c/1829475 to your computer and use it in GitHub Desktop.
Interpreted C++
# /*
this_md5="$(md5sum < "$0" | cut -d' ' -f1)"
last_md5="$(readelf -p SOURCE_FILE_HASH "${0%.cpp}" 2>/dev/null | awk '/\[ *0\]/ { print $3 }')"
if [ "$this_md5" != "$last_md5" ]; then
g++ -pipe -Wall -Wextra -std=c++0x -g -march=native -O3 -DTHIS_MD5="\"$this_md5\"" -o "${0%.cpp}" "$0" ||
exit 1
fi
exec "${0%.cpp}" "$@"
exit 1
# */
#ifndef THIS_MD5
# define THIS_MD5 "not set"
#endif
char MD5[] __attribute__((section ("SOURCE_FILE_HASH"))) = THIS_MD5;
#include <cstdlib>
#include <iostream>
using namespace std;
int main( int argc, char *argv[] )
{
while( argc-- )
cout << *argv++ << ' ';
cout << endl;
cout << "Hello World!" << endl;
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment