Hi Friends,
I am planning to use "__FILE__,__LIN E__,__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 want to verify that will I able to get this
information at any kind of build with all possible optimizations?
Regards
Vikram S 9 9415
Neo wrote:
Hi Friends,
I am planning to use "__FILE__,__LIN E__,__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 want to verify that will I able to get this
information at any kind of build with all possible optimizations?
Sounds like a tool issue rather than a C++ one, try a group dedicated to
your compiler.
--
Ian Collins.
Neo wrote:
Hi Friends,
I am planning to use "__FILE__,__LIN E__,__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 want to verify that will I able to get this
information at any kind of build with all possible optimizations?
__FILE__ and __LINE__ are always valid, and their meanings are specified
by the C++ standard. If a compiler switch disables them, the compiler
doesn't conform to the language definition when that switch is used.
__FUNCTION__ is not specified by the standard. You'll have to look at
your compiler's documentation to figure out what it does and when it
does it.
--
-- Pete
Roundhouse Consulting, Ltd. ( www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." ( www.petebecker.com/tr1book)
On Dec 21, 11:05 am, "Neo" <vikram.su...@g mail.comwrote:
Hi Friends,
I am planning to use "__FILE__,__LIN E__,__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 want to verify that will I able to get this
information at any kind of build with all possible optimizations?
__FUNCTION__ is not part of the C++ standard, but __LINE__ and __FILE__
are. Notice however that the value of __FILE__ can be either the
relative path (name of file) or the absolute path to the file at
compile time, or perhaps something in between.
--
Erik Wikström
Pete Becker wrote in message ...
>Neo wrote:
>Hi Friends, I am planning to use "__FILE__,__LIN E__,__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 want to verify that will I able to get this information at any kind of build with all possible optimizations?
__FILE__ and __LINE__ are always valid, and their meanings are specified by the C++ standard. If a compiler switch disables them, the compiler doesn't conform to the language definition when that switch is used.
__FUNCTION__ is not specified by the standard. You'll have to look at your compiler's documentation to figure out what it does and when it does it.
If the compiler is C99 complient, you can use '__func__' [1].
[1] - ref: GCC docs. (Some minor restrictions on concatenation.)
--
Bob R
POVrookie
BobR wrote:
Pete Becker wrote in message ...
>> __FUNCTION__ is not specified by the standard. You'll have to look at your compiler's documentation to figure out what it does and when it does it.
If the compiler is C99 complient, you can use '__func__' [1].
That's true if you're compiling C, but the C99 standard doesn't tell you
what __func__ does in a C++ member function, nor in a template function.
[1] - ref: GCC docs. (Some minor restrictions on concatenation.)
As I said: you'll have to look at your compiler's documentation. <g>
--
-- Pete
Roundhouse Consulting, Ltd. ( www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." ( www.petebecker.com/tr1book)
Pete Becker wrote in message ...
>BobR wrote:
>Pete Becker wrote in message ...
>>__FUNCTION_ _ is not specified by the standard. You'll have to look at your compiler's documentation to figure out what it does and when it does it.
If the compiler is C99 complient, you can use '__func__' [1].
That's true if you're compiling C, but the C99 standard doesn't tell you what __func__ does in a C++ member function, nor in a template function.
>[1] - ref: GCC docs. (Some minor restrictions on concatenation.)
As I said: you'll have to look at your compiler's documentation. <g>
I just know it works in GCC g++ without turning on any special flags or
includes(yeah, some are 'automatic' <g>).
Maybe someone with a faster access than I can try this on Comeau?:
// ------------------------------------
#include <iostream // #include <ostream>
void Test( std::ostream &cout ){
cout<<"\n_____[ "<<__func__ <<" ]_____"<<std::en dl;
// ------------------------------------
cout<<"_____[ "<<__func__ <<" ]__End\n"<<std:: endl;
return;
}
int main(){
Test( std::cout );
return 0;
}
// ------------------------------------
Did it make Comeau puke?
Sure is a handy 'feature' for testing, error output, etc..
--
Bob R
POVrookie
"BobR" <Re***********@ worldnet.att.ne twrote in message
news:mN******** *************@b gtnsc04-news.ops.worldn et.att.net...
>
Pete Becker wrote in message ...
>>Neo wrote:
>>Hi Friends, I am planning to use "__FILE__,__LIN E__,__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 want to verify that will I able to get this information at any kind of build with all possible optimizations?
__FILE__ and __LINE__ are always valid, and their meanings are specified by the C++ standard. If a compiler switch disables them, the compiler doesn't conform to the language definition when that switch is used.
__FUNCTION_ _ is not specified by the standard. You'll have to look at your compiler's documentation to figure out what it does and when it does it.
If the compiler is C99 complient, you can use '__func__' [1].
[1] - ref: GCC docs. (Some minor restrictions on concatenation.)
A problem with the __func__ and __FILE__ macros is that you can't
control the formatting. Sometimes you may want just a file name rather
than a full path, for example.
It's odd that the C99 __func__ macro is not __FUNC__, don't ya think?
Tony
Tony wrote in message ...
> "BobR" wrote in message ...
>Pete Becker wrote in message ...
>>>__FILE__ and __LINE__ are always valid, and their meanings are specified by the C++ standard. If a compiler switch disables them, the compiler doesn't conform to the language definition when that switch is used.
__FUNCTION __ is not specified by the standard. You'll have to look at your compiler's documentation to figure out what it does and when it does it.
If the compiler is C99 complient, you can use '__func__' [1].
[1] - ref: GCC docs. (Some minor restrictions on concatenation.)
A problem with the __func__ and __FILE__ macros is that you can't control the formatting. Sometimes you may want just a file name rather than a full path, for example.
std::string FuncName(__func __);
// change 'FuncName' to what you want.
> It's odd that the C99 __func__ macro is not __FUNC__, don't ya think? Tony
If '__func__' was a macro, it might have an all uppercase name.
From 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";
appeared, where function-name is the name of the lexically-enclosing
function. This name is the unadorned name of the function.
By this definition, __func__ is a variable, not a string literal. In
particular,
__func__ does not catenate with other string literals.
In C++, __FUNCTION__ and __PRETTY_FUNCTI ON__ are variables,
declared in the same way as __func__.
"
--
Bob R
POVrookie This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 malloc(int
x) as Xmalloc(int x)
Now I want to write a macro for Xmalloc which can log the location of the
file and the line and the number of bytes allocated.
|
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
respectively.
|
by: baumann.Pan |
last post by:
where are these macros defined? can I use it a release ver code?
|
by: Lukas Ruf |
last post by:
Dear all,
for debugging purposes, I like the pre-compiler macros
__FILE__, __FUNCTION__, __LINE__
I have been wondering if there is a short form of __FILE__ that
provides only the filename without path.
I am using gcc as available in Debian unstable:
|
by: Kenneth Brody |
last post by:
Am I correct that using __FILE__ and __LINE__ within a macro will expand
to the filename and line in which the macro is invoked, rather than where
it is defined?
For example, in a header file:
#ifdef DEBUG
#define LOGIT(note) DoLogging(__FILE__,__LINE__,note)
#else
#define LOGIT(note)
| |
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 and line number. Here I dont
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |