Hie,
Can I put __FILE__ and __LINE__ macros inside the class function which
may not be inline. And
void function()
{
classobject::Lo gInfo(...);
}
Internally LogInfo should log file name and line number. Here I dont
want user to pass those macros and also dont want to use any macros.
Is there any solution? 5 3362
On 2006-11-29 06:42, Neo wrote:
Hie,
Can I put __FILE__ and __LINE__ macros inside the class function which
may not be inline.
Since they are macros they are expanded by the pre-processor so whether
the functions are inline or not does not matter, it's the file and line
on which the code is written that is "returned", not where they are called.
And
void function()
{
classobject::Lo gInfo(...);
}
Internally LogInfo should log file name and line number. Here I dont
want user to pass those macros and also dont want to use any macros.
Is there any solution?
Do I understand you correctly in not wanting to pass the file and line
to the LogInfo()-function but would rather like it to know the line and
file magically in some way? Might work, depending on which filename and
line-number you want, as I said earlier, it's the filename and line-
number of the file where the code is written that is expanded.
--
Erik Wikström
What you wrote is correct. So is there any way to do it?
Erik Wikström wrote:
On 2006-11-29 06:42, Neo wrote:
Hie,
Can I put __FILE__ and __LINE__ macros inside the class function which
may not be inline.
Since they are macros they are expanded by the pre-processor so whether
the functions are inline or not does not matter, it's the file and line
on which the code is written that is "returned", not where they are called.
And
void function()
{
classobject::Lo gInfo(...);
}
Internally LogInfo should log file name and line number. Here I dont
want user to pass those macros and also dont want to use any macros.
Is there any solution?
Do I understand you correctly in not wanting to pass the file and line
to the LogInfo()-function but would rather like it to know the line and
file magically in some way? Might work, depending on which filename and
line-number you want, as I said earlier, it's the filename and line-
number of the file where the code is written that is expanded.
--
Erik Wikström
What you wrote is correct. So is there any way to do it?
Erik Wikström wrote:
On 2006-11-29 06:42, Neo wrote:
Hie,
Can I put __FILE__ and __LINE__ macros inside the class function which
may not be inline.
Since they are macros they are expanded by the pre-processor so whether
the functions are inline or not does not matter, it's the file and line
on which the code is written that is "returned", not where they are called.
And
void function()
{
classobject::Lo gInfo(...);
}
Internally LogInfo should log file name and line number. Here I dont
want user to pass those macros and also dont want to use any macros.
Is there any solution?
Do I understand you correctly in not wanting to pass the file and line
to the LogInfo()-function but would rather like it to know the line and
file magically in some way? Might work, depending on which filename and
line-number you want, as I said earlier, it's the filename and line-
number of the file where the code is written that is expanded.
--
Erik Wikström
Neo wrote:
>
Erik Wikström wrote:
On 2006-11-29 06:42, Neo wrote:
Hie,
Can I put __FILE__ and __LINE__ macros inside the class function which
may not be inline.
Since they are macros they are expanded by the pre-processor so whether
the functions are inline or not does not matter, it's the file and line
on which the code is written that is "returned", not where they are called.
And
>
void function()
{
classobject::Lo gInfo(...);
}
>
Internally LogInfo should log file name and line number. Here I dont
want user to pass those macros and also dont want to use any macros.
Is there any solution?
Do I understand you correctly in not wanting to pass the file and line
to the LogInfo()-function but would rather like it to know the line and
file magically in some way? Might work, depending on which filename and
line-number you want, as I said earlier, it's the filename and line-
number of the file where the code is written that is expanded.
What you wrote is correct. So is there any way to do it?
<don't top-post please>
What he meant is if you put the macros in the LogInfo function, like
struct classobject
{
void LogInfo(char const * msg)
{
somefilestream << __FILE__<<":"<< __LINE__<<msg;
}
};
It will always print the same __FILE__ (one where classobject is
defined) and the same __LINE__( that is, the one above)
You need to make LogInfo to take additional two parameters, a filename
and a line number
void LogInfo(char const *file, int line, char const * msg)
{
somefilestream << file <<":"<<line<<ms g;
}
and a macro
#define LOGINFO(X) classobject::Lo gInfo(__FILE__, __LINE__, X)
and use that instead
Neo wrote:
What you wrote is correct. So is there any way to do it?
Please don't top-post. Your replies belong following or interspersed
with properly trimmed quotes. See the majority of other posts in the
newsgroup, or the group FAQ list:
<http://www.parashift.c om/c++-faq-lite/how-to-post.html> 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: 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 welcome.
This will print the file name and line number followed by a format
string and a variable number of arguments. The key here is that you
MUST have a space between __LINE__ and the last comma, otherwise
__LINE__ gets eaten by the ## if...
|
by: baumann.Pan |
last post by:
where are these macros defined? can I use it a release ver code?
|
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: 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.
|
by: PengYu.UT |
last post by:
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
|
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 want to verify that will I able to get this
information at any kind of build with all possible optimizations?
Regards
Vikram S
|
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: 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: 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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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.
| |