Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion __FUNCTION__ ????

View Parsed - Show only message text

Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!ossa.telenet-ops.be!skynet.be!skynet.be!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: f...@genesis.demon.co.uk (Lawrence Kirby)
Newsgroups: comp.lang.c
Subject: Re: __FUNCTION__ ????
Date: Fri, 19 Oct 2001 12:44:14 GMT
Organization: none
Message-ID: <1003495454snz@genesis.demon.co.uk>
References: <47295485.0110190255.7f389085@posting.google.com>
Reply-To: f...@genesis.demon.co.uk
X-Trace: mail2news.demon.co.uk 1003502161 mail2news:27123 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!genesis.demon.co.uk
X-Newsreader: Demon Internet Simple News v1.31
Lines: 58

In article <47295485.0110190255.7f389...@posting.google.com>
           sob...@eudoramail.com "Sobhan Vezzu" writes:

>Hello All,
>
>         I understood that __FUNCTION__ is a preprocessor macro, which
>will substitute a file name. Similar to __FILE__ and __LINE__.

The C language doesn't define anything called __FUNCTION__ although it does
define __FILE__ and __LINE__

>         1) I have written a small code, only for __FUNCTION__ it
>prints as unknown why?

Perhaps because it isn't defined?

>What is the difference between __FILE__ and
>__FUNCTION__. When I comment #ifndef __FUNCTION block it prints the
>file name.

You compiler may provide __FUNCTION__ as an extension. Most likely it
will expand to the name of the function containing it. If it isn't
in a function then it won't be able to expand to anything. The new
C standard C99 does introduce something like this but it is called
__func__ and it is *not* a macro, it acts like the name of a static
variable within that function.

>         2) Where do I get a list of all the preprocessor macros.

Any good tutorial book on C should give one.

>#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)

There is a standard defined macro named assert(), this is an unwise name
to define in your code.

-- 
-----------------------------------------
Lawrence Kirby | f...@genesis.demon.co.uk
Wilts, England | 70734....@compuserve.com
-----------------------------------------


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