473,372 Members | 1,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

On use of C99 __func__ macro

Hello all,
Is it the same thing to do those two things:

#define WHERE printf("We are in %s", __func__)
void Function(void) {
WHERE;
}

And this:

void Function(void) {
#define WHERE printf("We are in %s", __func__)
WHERE;
}
--
Guillaume Dargaud
http://www.gdargaud.net/
"What is it about a man's cell phone going off in a theater that makes him
look more and more like Abe Lincoln ? - Jerry L. Embry.
Dec 5 '07 #1
10 8000
On Dec 5, 1:29 pm, "Guillaume Dargaud"
<use_the_form_on_my_contact_p...@www.gdargaud.netw rote:
Hello all,
Is it the same thing to do those two things:

#define WHERE printf("We are in %s", __func__)
void Function(void) {
WHERE;

}

And this:

void Function(void) {
#define WHERE printf("We are in %s", __func__)
WHERE;

}
There's no __func__ in C99.
Dec 5 '07 #2
vi******@gmail.com schrieb:
On Dec 5, 1:29 pm, "Guillaume Dargaud"
<use_the_form_on_my_contact_p...@www.gdargaud.netw rote:
>#define WHERE printf("We are in %s", __func__)
void Function(void) {
WHERE;

}

And this:

void Function(void) {
#define WHERE printf("We are in %s", __func__)
WHERE;

}
Yes. Both expands to:

void Function(void) {
printf("We are in %s", __func__);

}
There's no __func__ in C99.
There is.

6.4.2.2 #1 says:

The identifier __func__ shall be implicitly declared by the translator
as if, immediately following the opening brace of each function
definition, the declaration

static const char __func__[] = "function-name";

appeared, where function-name is the name of the lexically- enclosing
function.

--
OMG,-10==10 in linux!
Dec 5 '07 #3
In article <fj**********@ccpntc8.in2p3.fr>,
Guillaume Dargaud <us*****************************@www.gdargaud.netw rote:
>Is it the same thing to do those two things:

#define WHERE printf("We are in %s", __func__)
void Function(void) {
WHERE;
}

And this:

void Function(void) {
#define WHERE printf("We are in %s", __func__)
WHERE;
}
Yes, because __func__ is required to be like a variable, rather than
a preprocessor macro.

-- Richard

--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Dec 5 '07 #4
vi******@gmail.com wrote:
On Dec 5, 1:29 pm, "Guillaume Dargaud"
<use_the_form_on_my_contact_p...@www.gdargaud.netw rote:
>Hello all,
Is it the same thing to do those two things:

#define WHERE printf("We are in %s", __func__)
void Function(void) {
WHERE;

}

And this:

void Function(void) {
#define WHERE printf("We are in %s", __func__)
WHERE;

}

There's no __func__ in C99.
C & V please.

Dec 5 '07 #5
On Dec 5, 8:43 am, santosh <santosh....@gmail.comwrote:
vipps...@gmail.com wrote:
On Dec 5, 1:29 pm, "Guillaume Dargaud"
<use_the_form_on_my_contact_p...@www.gdargaud.netw rote:
Hello all,
Is it the same thing to do those two things:
#define WHERE printf("We are in %s", __func__)
void Function(void) {
WHERE;
}
And this:
void Function(void) {
#define WHERE printf("We are in %s", __func__)
WHERE;
}
There's no __func__ in C99.

C & V please.- Hide quoted text -
Why it's right here:

http://www.youtube.com/watch?v=6lj9_zBobJs
Dec 5 '07 #6
On Dec 5, 3:43 pm, santosh <santosh....@gmail.comwrote:
vipps...@gmail.com wrote:
On Dec 5, 1:29 pm, "Guillaume Dargaud"
<use_the_form_on_my_contact_p...@www.gdargaud.netw rote:
Hello all,
Is it the same thing to do those two things:
#define WHERE printf("We are in %s", __func__)
void Function(void) {
WHERE;
}
And this:
void Function(void) {
#define WHERE printf("We are in %s", __func__)
WHERE;
}
There's no __func__ in C99.

C & V please.
I answered from memory.
Can't always be right on usenet :-)
Dec 5 '07 #7
Richard Tobin wrote:
In article <fj**********@ccpntc8.in2p3.fr>,
Guillaume Dargaud <us*****************************@www.gdargaud.netw rote:
>Is it the same thing to do those two things:

#define WHERE printf("We are in %s", __func__)
void Function(void) {
WHERE;
}

And this:

void Function(void) {
#define WHERE printf("We are in %s", __func__)
WHERE;
}

Yes, because __func__ is required to be like a variable, rather than
a preprocessor macro.
Not "because": even if it were a macro the answer would still be yes.

Neil.
Dec 5 '07 #8
In article <47*********************@news2.asahi-net.or.jp>,
Neil Booth <dev@nullwrote:
>>Is it the same thing to do those two things:

#define WHERE printf("We are in %s", __func__)
void Function(void) {
WHERE;
}

And this:

void Function(void) {
#define WHERE printf("We are in %s", __func__)
WHERE;
}
>Yes, because __func__ is required to be like a variable, rather than
a preprocessor macro.
>Not "because": even if it were a macro the answer would still be yes.
Um yes. I should have said "... rather than some magic thing that
gets replaced when it is first encountered in the text".

-- Richard

--
:wq
Dec 5 '07 #9
>>Not "because": even if it were a macro the answer would still be yes.
Um yes. I should have said "... rather than some magic thing that
gets replaced when it is first encountered in the text".
Thanks, that sums it up nicely.
--
Guillaume Dargaud
http://www.gdargaud.net/
Dec 5 '07 #10
vi******@gmail.com wrote:
>
There's no __func__ in C99.
Just for the record, there is a __func__ in C99, ref. 6.4.2.2.

--
Tor <bw****@wvtqvm.vw | tr i-za-h a-z>
Dec 9 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: chasdev | last post by:
I'm using a preprocessor/compiler (HP aCC) that doesn't support the __func__ macro (a la gcc: expands to the name of the enclosing function). I've thought about using an extra preprocessing step,...
20
by: Jim Ford | last post by:
I understand that some compilers define a symbol that can be used anywhere in the code in order to find out, at run time, the name of the file where the code corresponding to the current execution...
19
by: Mockey Chen | last post by:
I using #define as following: #include <stdio.h> #define LOG_PREFIX "Current function: <" __FUNCTION__ ">: " int main() { printf(LOG_PREFIX "some thing.\n"); return 0; }
9
by: dave_140390 | last post by:
Hi, Is there a clean way to determine at compile-time whether your compiler supports the __func__ feature? I mean, something similar to the following (which tests for the existence of macro...
1
by: somenath | last post by:
Hi ALL , I need to print the name of the function as my debug message. I have tried the following way #include<stdio.h> #include<stdlib.h> #define __STR(x) _VAL(x) #define _VAL(x) #x int...
33
by: Peng Yu | last post by:
Hi, __PRETTY_FUNCTION__ is a macro that gives function name, etc. I'm wondering if there is a macro to get the class name inside a member function. Thanks, Peng
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.