Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!seismo!vrdxhq!deller From: deller@vrdxhq.UUCP Newsgroups: comp.lang.c Subject: Incrementing of preprocessor symbols Message-ID: <3424@vrdxhq.UUCP> Date: Wed, 15-Apr-87 18:39:42 EST Article-I.D.: vrdxhq.3424 Posted: Wed Apr 15 18:39:42 1987 Date-Received: Fri, 17-Apr-87 05:01:22 EST Organization: Verdix Corporation, Chantilly, VA Lines: 36 Keywords: C #define Help please. We have a program in which we would like to use something like: assert( ) ; and have it expand to if ( ! ) error_call( , __FILE__, __LINE__ ) ; (the __FILE__ and __LINE__ are preprocessed into a quoted string that is the filename being compiled, and an integer that is the line number, in the source, where the symbol appears). Everything is quite easy to do with a #define, except the handling of . We would like the to increment with each expansion encountered in the source, i.e. with each "assert" in the text. The helps distinguish the different assertions on VMS, where C does not expand __FILE__ and __LINE__ as it does on Sun, Sequent, VAX UNIX, and VAX Ultrix. So, the problem is how to get an that increments with each usage in the source. Note that should NOT be incremented each time the statment is encountered during execution; a lexical increment is desired. We are not looking to use a pre-preprocessor that modifies the sources as they are fed to the "cc" command (piping the source messes up __FILE__, and we can't afford the extra time to make file copies); we are looking for a solution entirely within the C preprocessor. I would note that any self-respecting macro facility for any assembler can do this sort of thing with its eyes closed and one macro expansion behind its back. If as I am beginning to suspect, this is not possible with C, then perhaps the C standards committee might take note. Steven Deller -- ::= | | | {verdix,seismo,umcp-cs}!vrdxhq!deller