Skip to content

Instantly share code, notes, and snippets.

@simonlindholm
Created November 17, 2015 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonlindholm/8e5f1e595afd6ac28560 to your computer and use it in GitHub Desktop.
Save simonlindholm/8e5f1e595afd6ac28560 to your computer and use it in GitHub Desktop.
#!/bin/bash
cpp -m32 -P -nostdinc ttmath/ttmathuint.h | \
tr '\n' ' ' | \
sed 's/\s\+/ /g' | \
sed 's/\([^a-zA-Z0-9'\''_]\) /\1/g' | \
sed 's/ \([^a-zA-Z0-9'\''_%\($]\)/\1/g' | \
sed 's/^ //' | \
sed 's/\<return\>/R /g' | \
sed 's/\<operator\>/O/g' | \
sed 's/\<uint\>/U/g' | \
sed 's/\<UInt\>/V/g' | \
sed 's/\<value_size\>/S/g' | \
sed 's/\<const\>/C/g' | \
sed 's/\<table\>/T/g' | \
sed 's/std:://g' | \
sed 's/ / /g' | \
cat > incl.h && wc -c incl.h
@simonlindholm
Copy link
Author

Usage:

#include <bits/stdc++.h>
using namespace std;
#define O operator
#define R return
#define C const
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#ifdef __x86_64__
#error ttmath requires -m32
#endif
// ttmath, BSD licensed:
#include "incl.h"
// (paste incl.h here manually for submission to SPOJ)
#pragma GCC diagnostic pop
#undef C
#undef R
#undef O

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