Re: [ Code ] My previous post...

From: George (greerga@DRAGON.HAM.MUOHIO.EDU)
Date: 08/01/97


On Fri, 1 Aug 1997, Chaotic wrote:

>#define FREE(ptr)      (                                    \
>                             if (ptr == NULL)               \
>                             log("SYSERR: NULL pointer");   \
>                         else {                             \
>                             free(ptr);                     \
>                             ptr = NULL;                    \
>                         }                                  \
>                       )

Useful preprocessor macros. (in gcc, others I don't know)
__FILE__ : string containing the file the code is in.
__LINE__ : string containing line in source code the value is
__FUNCTION__ : string containing the function the value is in.

ie:
sprintf(buf, "Error in %s:%s, function %s().", __FILE__, __LINE__,
        __FUNCTION__);
log(buf);

--
greerga@muohio.edu me@null.net | Genius may have its limitations, but stupidity
http://www.muohio.edu/~greerga | is not thus handicapped. -- Elbert Hubbard


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST