Message from discussion
__FUNCTION__ ????
Path: archiver1.google.com!postnews1.google.com!not-for-mail
From: sob...@eudoramail.com (Sobhan Vezzu)
Newsgroups: comp.lang.c
Subject: __FUNCTION__ ????
Date: 19 Oct 2001 03:55:05 -0700
Organization: http://groups.google.com/
Lines: 54
Message-ID: <47295485.0110190255.7f389085@posting.google.com>
NNTP-Posting-Host: 202.56.254.13
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1003488906 11077 127.0.0.1 (19 Oct 2001 10:55:06 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 19 Oct 2001 10:55:06 GMT
Hello All,
I understood that __FUNCTION__ is a preprocessor macro, which
will substitute a file name. Similar to __FILE__ and __LINE__.
1) I have written a small code, only for __FUNCTION__ it
prints as unknown why? What is the difference between __FILE__ and
__FUNCTION__. When I comment #ifndef __FUNCTION block it prints the
file name.
2) Where do I get a list of all the preprocessor macros.
#include <stdio.h>
#include <errno.h>
#ifndef __LINE__
#define __LINE__ 0
#endif
#ifndef __FILE__
#define __FILE__ "Unknown"
#endif
#ifndef __FUNCTION__
#define __FUNCTION__ "Unknown"
#endif
int assert(int bool, int line, char *file, char *fun)
{
char mesg[100];
sprintf(mesg, "line: %d, file: %s, function: %s\nError ", line, file,
fun);
if(bool){
perror(mesg);
errno = 0;
}
return 1;
}
int main()
{
char info[50];
FILE *fp;
errno = 0;
fp = fopen("ex.dat", "r");
assert(fp == NULL, __LINE__ - 1, __FILE__, __FUNCTION__);
fp = fopen("t.c", "r");
assert(errno != 0, __LINE__, __FILE__, __FUNCTION__);
return 1;
}
bye,
Sobhan