Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site yale.ARPA Path: utzoo!linus!decvax!yale!grace From: grace@yale.ARPA (Joseph Grace) Newsgroups: net.lang.c Subject: How about a predefined #FILE, #PATH and #FUNCTION for C? Message-ID: <312@yale.ARPA> Date: Sun, 26-Jan-86 21:42:13 EST Article-I.D.: yale.312 Posted: Sun Jan 26 21:42:13 1986 Date-Received: Thu, 6-Feb-86 05:38:12 EST Organization: Yale University CS Dept., New Haven CT Lines: 58 To explain what I mean... definition by example: #PATH ==> /usr/fred/hello.c #FILE ==> hello.c #FUNCTION ==> main (N.B.: no quotation marks.) 2 problems that these predefined macros would help (me) with: 1) When debugging, I always like to include in my error messages, the name of the file where the error message originated. However, when I rename files with more meaningful names, or simply copy a function from one file to another, the old filename still shows up in the error (or other) messages. #FILE would put a stop to this. 2) #FILE could also help in writing a header file, e.g., error.h, that has standard error messages that will print the filename of the file that the message printed from. Here is an example where these predefined macros would be useful: (#FILE ==> FILE since compiler complains "illegal macro name" with #FILE.) error.h: #define TEST printf ("FILE: error has occurred\n"); test.c: #define FILE test1 #include "test.h" main() { TEST; } output of test (on BSD 4.2 Pyramid): FILE: error has occurred /* not "test: error has occurred" as I would prefer */ #FILE, #PATH and #FUNCTION would solve these problems. If someone knows a way around these problems, I would appreciate hearing about it. Otherwise, maybe these would be good additions to the C standard... Sincerely, Joseph R. Grace ...decvax!yale!grace p.s. #PATH is nice for files that reside in many directories. #FUNCTION is nice for precision.