/* stdc.h -- JT standard C/C++ header file, cut-down for modern code only */ /* $Id$ */ /* * ***** THIS VERSION IS FOR ANSI/ISO C AND C++ ***** */ /* this header file is idempotent */ #ifndef STDC_H_SEEN #define STDC_H_SEEN /******************************************************************************/ /* * Fake "then" keyword for if statement, to make "then" and "else" * symmetrical: * * usage: * if (foo) * then bar; * else baz; */ #define then /* empty */ /******************************************************************************/ /* * C/C++ compatability: */ /* use this in prototypes like this: extern C_FUNCTION void foo(...) */ #ifdef __cplusplus #define C_FUNCTION "C" #else #define C_FUNCTION /* empty */ #endif /******************************************************************************/ /* * misc stuff */ #ifdef M_PI /* usually defined in */ #define PI M_PI #endif #define STRING_EQUAL(s_,t_) (strcmp(s_,t_) == 0) /* C library uses abs() for integer absolute value; I prefer iabs() */ #define iabs(x_) abs(x_) #ifndef FILENAME_MAX /* we must be on a wierd system with an ancient */ /* ==> try defining this ourselves, hope it works... */ #define FILENAME_MAX 4095 #endif /******************************************************************************/ #ifdef __cplusplus namespace jtutil { #endif /* * Standard error-handling function: print a message to stderr, then * exit() or abort(). (Does *not* return to caller.) * * This function is declared to return an int in order that it may be * easily used in conditional expressions like * foo = bar_ok ? baz(bar) : error_exit(...); */ extern C_FUNCTION int error_exit(int exit_code, const char *format, ...) #ifdef __GNUC__ __attribute__ ((noreturn)) __attribute__ ((format(printf,2,3))) #endif ; /* * error_exit() uses the following exit() codes: * OK_EXIT ==> everything's under control * ERROR_EXIT ==> something bad has happened * PANIC_EXIT ==> diasaster ==> force (eg) core dump, stack trace */ #ifdef VMS #define OK_EXIT 1 #define ERROR_EXIT 3 #define PANIC_EXIT (-1) #else #define OK_EXIT 0 #define ERROR_EXIT 1 #define PANIC_EXIT (-1) #endif #ifdef __cplusplus }; /* namespace jtutil:: */ #endif /******************************************************************************/ #endif /* STDC_H_SEEN */