Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion __FUNCTION__ ????
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Sobhan Vezzu  
View profile   Translate to Translated (View Original)
 More options 19 Oct 2001, 11:55
Newsgroups: comp.lang.c
From: sob...@eudoramail.com (Sobhan Vezzu)
Date: 19 Oct 2001 03:55:05 -0700
Local: Fri 19 Oct 2001 11:55
Subject: __FUNCTION__ ????
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

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google