Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site dataioDataio.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!tektronix!uw-beaver!uw-june!entropy!dataio!bright From: bright@dataioDataio.UUCP (Walter Bright) Newsgroups: net.lang.c Subject: Re: How about a predefined #FILE, #PATH and #FUNCTION for C? Message-ID: <900@dataioDataio.UUCP> Date: Fri, 31-Jan-86 13:00:53 EST Article-I.D.: dataioDa.900 Posted: Fri Jan 31 13:00:53 1986 Date-Received: Sun, 2-Feb-86 05:58:35 EST References: <312@yale.ARPA <887@h-sc1.UUCP> Reply-To: bright@dataio.UUCP (Walter Bright Organization: Data I/O Corp., Redmond WA Lines: 25 In article <887@h-sc1.UUCP> augart@h-sc1.UUCP (Steven Augart) writes: >Could someone on a non-4.2/4.3 BSD machine tell us if this facility is >part of other preprocessors as well? Thanks. __LINE__ and __FILE__ are supported by the Datalight C compiler for the IBM PC. In fact, they are supported by most C compilers. They are primarilly useful to support the following macro: #define assert(e) ((e) || assert_fail("e",__LINE__,__FILE__)) assert_fail(expression,line,file) char *expression,*file; int line; { fprintf(stderr,"expression '%s' failed at line %d in file '%s'\n", expression,line,file); exit(1); } The assert macro generates code that guarantees that expression e evaluates to true, or else tells you where it failed. Sprinkling your code with assert()s in the right places can greatly facilitate debugging (especially on the IBM PC which has no memory protection). Note the "e" in the macro definition. This won't work on all compilers, you will have to use a variant that your compiler supports.