#! /usr/bin/env python

import sys
import re
import os
import commands

source = """
#include <pthread.h>
int main(int argc, char** argv){
  pthread_cond_t grab_me = PTHREAD_COND_INITIALIZER; 
  return 0;
}
"""

open("conftest.c", "w").write(source)


cc = sys.argv[1]

cmd = "%s -E conftest.c" % (cc)
text = commands.getoutput(cmd)

os.remove("conftest.c")

retext = r'grab_me = (.*?);'
regexp = re.compile(retext)
match = regexp.search(text)

if not match:
    sys.exit("Could not process pthread.h")

print match.groups()[0]

