Hi,
I want to make a debugger for my application.
which also print line number and and file name.
and also accept variable argument list.
We don't need to pass line number and file name at the time of call.
So i have have to make this debugger by #define ?
Exmp --
//MyCpp.c
...
...
...
MyTrace("Hi");
int DD = 10 ;
MyTrace("Hi=%d" , DD);
...
...
...
//End Of File
=========O/P=============
Line 4 File MyCpp.c - Hi
Line 6 File MyCpp.c - Hi=10
I strongly suggest you using a real debugger but try something like this:
~C++ : #define MyTrace() std::cout << "line " << __LINE__ << " file " << __FILE__ the tilde means "don't use this in C++"
C : #define MyTrace() printf("line %d file %s - ", __LINE__, __FILE__ )
These won't print your string, to make MyTrace("Hi=%d" , DD); work you would need something like variadic macros.