home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!sun-barr!ames!elroy.jpl.nasa.gov!usc!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!ulysses.cs.umn.edu!kencham
- From: kencham@ulysses.cs.umn.edu (Deepak)
- Subject: Function name : C preprocessor question
- Message-ID: <1992Jul30.224332.3277@news2.cis.umn.edu>
- Followup-To: comp.lang.c
- Sender: news@news2.cis.umn.edu (Usenet News Administration)
- Nntp-Posting-Host: ulysses.cs.umn.edu
- Organization: University of Minnesota
- Date: Thu, 30 Jul 1992 22:43:32 GMT
- Lines: 44
-
- O, C-gurus !!
-
- I was wondering if there was anyway to get the name of function that is being currently executed. The scenario is as follows :
-
- Suppose you have a debugging macro that is defined as follows :
-
- #define DEBUGSTR(x) fprintf(stderr , "In File : %s , Function :%s error : %s"\
- __FILE__ , <GOD-KNOWS-WHAT> , x )
-
- and somewhere in file foobar.c I have the following code :
-
- ....
- ...
- .
- foobarfunction(foobarvar)
- foobarstruct foobarvar;
- {
- int foo;
-
- if ( foobarvar == 0 ) DEBUGSTR("foobarvar was zero");
- blah !
- blah !!
- blah !!
- }
- .
- ..
- ...
-
- The result should be that if foobarvar happened to be 0 then the following should be printed on stderr.
-
- In File : foobar.c , Function :foobarfunction error : foobarvar was zero
-
- Is it possible to do this using the preprocessor without passing the name of the function as an additional argument to the macro ?
-
- Silly question ,eh ?
-
- Deepak
- --
- ********************************************************************************
- * Deepak R. Kenchammana-Hosekote ******* ****** *
- * Dept. of CSci, University of Minnesota *** *** *** *** *
- * 1:((612) 626-8396(o),(612) 339-8997(r)) *** ***** *** *
- * kencham@ulysses.cs.umn.edu ***** ***** *
- ********************************************************************************
-