Is there a way to print out the name of the function calling another
function? For example:
void foo()
{
debugPrint("Beginning calculation...");
}
void debutPrint(string text)
{
cout << SOMETHING << text << endl;
}
so that i would get something like
"(foo) Beginning Calculation..." 8 2137
On Thu, 25 Oct 2007 16:02:05 -0000, Travis <tr***********@gmail.com>
wrote:
>Is there a way to print out the name of the function calling another function? For example:
void foo() { debugPrint("Beginning calculation..."); }
void debutPrint(string text) {
cout << SOMETHING << text << endl; }
so that i would get something like
"(foo) Beginning Calculation..."
void foo()
{
debugPrint(__FUNCTION__,"Beginning calculation...")
}
void debugPrint(string func, string msg)
{
cout << "(" << func << ") " << msg << endl;
}
Would that do it?
--
PGP key ID 0xEB7180EC
Travis wrote:
Is there a way to print out the name of the function calling another
function? For example:
void foo()
{
debugPrint("Beginning calculation...");
}
void debutPrint(string text)
{
cout << SOMETHING << text << endl;
}
so that i would get something like
"(foo) Beginning Calculation..."
void foo()
{
debugPrint("foo", "Beginning calculation...");
}
void debugPrint(const std::string& where,
const std::string& text)
{
std::cout << where << ": " << text << std::endl;
}
On Oct 25, 9:12 am, Keith Willis <m...@privacy.netwrote:
On Thu, 25 Oct 2007 16:02:05 -0000, Travis <travis.bow...@gmail.com>
wrote:
Is there a way to print out the name of the function calling another
function? For example:
void foo()
{
debugPrint("Beginning calculation...");
}
void debutPrint(string text)
{
cout << SOMETHING << text << endl;
}
so that i would get something like
"(foo) Beginning Calculation..."
void foo()
{
debugPrint(__FUNCTION__,"Beginning calculation...")
}
void debugPrint(string func, string msg)
{
cout << "(" << func << ") " << msg << endl;
}
Would that do it?
--
PGP key ID 0xEB7180EC
Yeah that's actually what i have implemented now. The __FUNCTION__
thing is great but is a gcc/g++ only thing right? I was more curious
if there was a c++ thing I wasn't aware of.
On Oct 25, 5:40 pm, Travis <travis.bow...@gmail.comwrote:
On Oct 25, 9:12 am, Keith Willis <m...@privacy.netwrote:
On Thu, 25 Oct 2007 16:02:05 -0000, Travis <travis.bow...@gmail.com>
wrote:
>Is there a way to print out the name of the function calling another
>function? For example:
>void foo()
>{
>debugPrint("Beginning calculation...");
>}
>void debutPrint(string text)
>{
cout << SOMETHING << text << endl;
>}
>so that i would get something like
>"(foo) Beginning Calculation..."
void foo()
{
debugPrint(__FUNCTION__,"Beginning calculation...")
}
void debugPrint(string func, string msg)
{
cout << "(" << func << ") " << msg << endl;
}
Would that do it?
--
PGP key ID 0xEB7180EC
Yeah that's actually what i have implemented now. The __FUNCTION__
thing is great but is a gcc/g++ only thing right? I was more curious
if there was a c++ thing I wasn't aware of.- Hide quoted text -
- Show quoted text -
I have used __FUNCTION__ in microsoft vc++
On 2007-10-25 18:59, ho******@gmail.com wrote:
On Oct 25, 5:40 pm, Travis <travis.bow...@gmail.comwrote:
>On Oct 25, 9:12 am, Keith Willis <m...@privacy.netwrote:
On Thu, 25 Oct 2007 16:02:05 -0000, Travis <travis.bow...@gmail.com>
wrote:
>Is there a way to print out the name of the function calling another function? For example:
>void foo() { debugPrint("Beginning calculation..."); }
>void debutPrint(string text) {
cout << SOMETHING << text << endl; }
>so that i would get something like
>"(foo) Beginning Calculation..."
void foo()
{
debugPrint(__FUNCTION__,"Beginning calculation...")
}
void debugPrint(string func, string msg)
{
cout << "(" << func << ") " << msg << endl;
}
Would that do it?
--
PGP key ID 0xEB7180EC
Yeah that's actually what i have implemented now. The __FUNCTION__ thing is great but is a gcc/g++ only thing right? I was more curious if there was a c++ thing I wasn't aware of.- Hide quoted text -
I have used __FUNCTION__ in microsoft vc++
I thought __FUNCTION__ was VC and __func__ gcc. Anyway, in the next
version of the standard it will be __func__ (which I personally do not
like since it it is not similar to __LINE__ and __FILE__) as in C.
--
Erik Wikström
Travis wrote:
Is there a way to print out the name of the function calling another
function? For example:
void foo()
{
debugPrint("Beginning calculation...");
}
void debutPrint(string text)
{
cout << SOMETHING << text << endl;
}
so that i would get something like
"(foo) Beginning Calculation..."
In some compilers you can do this trick:
#define debugPrint(a) debugPrintFunction(__FUNCTION__, a)
void debugPrintFunction(string const& func, string const& text)
{
cout << "(" << func << ") " << text << endl;
}
void foo()
{
debugPrint("blah");
}
The macro __FUNCTION__ is not standard (yet, anyway) but some compilers
do implement it to become the name of the current function (a convention
of sorts). IIRC, anyway.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Erik Wikström wrote in message...
On 2007-10-25 18:59, ho******@gmail.com wrote:
On Oct 25, 5:40 pm, Travis <travis.bow...@gmail.comwrote:
Yeah that's actually what i have implemented now. The __FUNCTION__
thing is great but is a gcc/g++ only thing right? I was more curious
if there was a c++ thing I wasn't aware of.- Hide quoted text -
I have used __FUNCTION__ in microsoft vc++
I thought __FUNCTION__ was VC and __func__ gcc. Anyway, in the next
version of the standard it will be __func__ (which I personally do not
like since it it is not similar to __LINE__ and __FILE__) as in C.
GCC has __FUNCTION__ and __PRETTY_FUNCTION__. __func__ is C99.
From GCC docs:
"
Function Names as Strings
GCC predefines two magic identifiers to hold the name of the current
function. The identifier __FUNCTION__ holds the name of the function as it
appears in the source. The identifier __PRETTY_FUNCTION__ holds the name of
the function pretty printed in a language specific fashion.
"
.... and later:
"
Note that these semantics are deprecated, and that GCC 3.2 will handle
__FUNCTION__ and __PRETTY_FUNCTION__ the same way as __func__. __func__ is
defined by the ISO standard C99:
"
--
Bob R
POVrookie
On Oct 25, 12:56 pm, Erik Wikström <Erik-wikst...@telia.comwrote:
I thought __FUNCTION__ was VC and __func__ gcc. Anyway, in the next
version of the standard it will be __func__ (which I personally do not
like since it it is not similar to __LINE__ and __FILE__) as in C.
Not really pertinent to the discussion at hand, but I believe it's in
lowercase because it's a "predefined identifier" and not a macro. The
C99 standard describes it as if the following appeared right after the
opening brace of a function definition:
static const char __func__[] = "function-name"; This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ron_Adam |
last post by:
Hi, Sometimes it just helps to see what's going on, so I've been
trying to write a tool to examine what names are pointing to what
objects in the current scope.
This still has some glitches,...
|
by: Suzanka |
last post by:
Hello,
I have an application written in C# on visual studio .NET. It is a web
aplication.
The application consists of many different forms, that users
occassionaly want to print out for filing....
|
by: CsharpNewcommer |
last post by:
Hi
I have designed a form containing data and I want to print that form and the
data as it appears in the Windows Form. I am a beginner with C# and I have
read several "help"s on PrintPage,...
|
by: DazedAndConfused |
last post by:
I have a 8.5 x 11 landscape document with about 1/4 inch of space on the
left and right where there is no print.
The document displays perfect in print preview, but when I print it, about
1/2 inch...
|
by: Vincent |
last post by:
Dear all,
I have implemented a class to export the content of RichTextBox to
image in WYSISYG mode so that line breaks on the screen are the same as
exported.
C# Code:
public struct...
|
by: junky_fellow |
last post by:
Hi,
To print the pointer using printf(), we convert it to (void *) .
printf("%p",(void *)ptr);
My question is how printf() determine which type of pointer is passed
to it and
prints its value...
|
by: Neo Geshel |
last post by:
Greetings.
BACKGROUND:
My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are
delivered as application/xhtml+xml for all non-MS web clients, and as
text/xml for all MS web...
|
by: Germaris |
last post by:
Hi there!
I implemented a printing function which is working nice even for multiple pages.
Problem is as follows...
Say we have a text 100 lines long.
Each page can hold 80 lines.
We should...
|
by: billelev |
last post by:
Here is some code that I have adapted slightly. It allows a report to be printed to a specific location.
It works by calling SaveReportAsPDF and specifying the access report name, and the root...
|
by: Glenn |
last post by:
I am writing a program for field work that will use a receipt
printer. I need to be able to adjust the page settings prior to
printing depending on how much needs to be printed. I have been able...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: 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,...
|
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...
|
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |