24.5. Checking for the Availability of a typedef

Check for the availability of a typedef by using the CheckType method:


    env = Environment()
    conf = Configure(env)
    if not conf.CheckType('off_t'):
        print 'Did not find off_t typedef, assuming int'
        conf.env.Append(CCFLAGS = '-Doff_t=int')
    env = conf.Finish()
    

You can also add a string that will be placed at the beginning of the test file that will be used to check for the typedef. This provide a way to specify files that must be included to find the typedef:


    env = Environment()
    conf = Configure(env)
    if not conf.CheckType('off_t', '#include <sys/types.h>\n'):
        print 'Did not find off_t typedef, assuming int'
        conf.env.Append(CCFLAGS = '-Doff_t=int')
    env = conf.Finish()