473,473 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

combine __FILE__, __LINE__, __PRETTY_FUNCTION__

Hi,

I want to print out error message from all the three macros __FILE__,
__LINE__, __PRETTY_FUNCTION__. I'm wondering if there is one macro
which serves equivalently as the combinations of the three.

Thanks,
Peng

Nov 3 '06 #1
5 12377
Pe*******@gmail.com wrote:
I want to print out error message from all the three macros __FILE__,
__LINE__, __PRETTY_FUNCTION__. I'm wondering if there is one macro
which serves equivalently as the combinations of the three.
Since __PRETTY_FUNCTION__ is non-standard the question has no
affirmative answer in Standard C++.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 3 '06 #2

Victor Bazarov wrote in message
<27******************************@comcast.com>.. .
>Pe*******@gmail.com wrote:
>I want to print out error message from all the three macros __FILE__,
__LINE__, __PRETTY_FUNCTION__. I'm wondering if there is one macro
which serves equivalently as the combinations of the three.

Since __PRETTY_FUNCTION__ is non-standard the question has no
affirmative answer in Standard C++.
My GCC docs stated that there is a '__func__' var. in standard, but, I've not
confirmed it.

// "By this definition, __func__ is a variable, not a string literal.
// In particular, __func__ does not catenate with other string literals".
std::cout<<" __func__ ="<<__func__<<std::endl;
std::string FuncName( __func__ );
std::cout<<" string FuncName ="<<FuncName<<std::endl;

--
Bob R
POVrookie
Nov 3 '06 #3
Pe*******@gmail.com wrote:
Hi,

I want to print out error message from all the three macros __FILE__,
__LINE__, __PRETTY_FUNCTION__. I'm wondering if there is one macro
which serves equivalently as the combinations of the three.
Why not write your own?

#define combo \
cerr << "File: " << __FILE__ << ", line: " << __LINE__ \
<< ", function: " << __PRETTY_FUNCTION__ << endl;

HTH,
- J.
Nov 3 '06 #4
BobR wrote:
>
My GCC docs stated that there is a '__func__' var. in standard, but, I've not
confirmed it.
There is no __func__ macro, variable, or whatever else in standard C++.

--

-- Pete

Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." For more information about this book, see
www.petebecker.com/tr1book.
Nov 3 '06 #5

Pete Becker wrote in message ...
>BobR wrote:
>>
My GCC docs stated that there is a '__func__' var. in standard, but, I've
not
>confirmed it.

There is no __func__ macro, variable, or whatever else in standard C++.
Ah, I see, it's C.

--- GCC docs ---

__func__ is defined by the ISO standard C99:

The identifier __func__ is implicitly declared by the translator
as if, immediately following the opening brace of each function
definition, the declaration
static const char __func__[] = "function-name";

--
Bob R
POVrookie
Nov 11 '06 #6

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

Similar topics

2
by: Thomas | last post by:
Hello im using Visual Studio .net And have troubel with the following line ClassA::~ClassA() { cerr<<__PRETTY_FUNCTION__<<"\n"; \\this works with g++ } on compiling I get this back:
1
by: Spry | last post by:
Hi, I wanted to write macros for finding the number of memory allocations and deallocations also wanted to find the locations. The code I have is a pretty big one. I have a wrapper on top of...
9
by: qazmlp | last post by:
How exactly __FILE__ and __LINE__ macros are defined? Or, Is the definition of these macros implementation dependent ? I am wondering how easily they can get the file name and line number...
5
by: jake1138 | last post by:
I couldn't find an example of this anywhere so I post it in the hope that someone finds it useful. I believe this is compiler specific (I'm using gcc), as C99 defines __VA_ARGS__. Comments are...
5
by: baumann.Pan | last post by:
where are these macros defined? can I use it a release ver code?
1
by: cbro | last post by:
Is there a C# equivalent for the C++ macros __FILE__ and __LINE__ ? They are quite handy for pinpointing where an event log entry was generated. I am using Visual Studio.NET 2003.
5
by: Neo | last post by:
Hie, Can I put __FILE__ and __LINE__ macros inside the class function which may not be inline. And void function() { classobject::LogInfo(...); } Internally LogInfo should log file name...
9
by: Neo | last post by:
Hi Friends, I am planning to use "__FILE__,__LINE__,__FUNCTION__ " for a logging component in my class. In debug build I gets all information. I tried with release mode also and it works. But I...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.