K
Kenneth Brody
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)
#endif
And on line 123 of "foo.c", you have:
LOGIT("whatever")
If DEBUG is defined, this will expand to:
DoLogging("foo.c",123,"whatever")
as opposed to:
DoLogging("something.h",42,"whatever")
Is this guaranteed?
What about a macro-within-a-macro, as in:
#define LOGIT(note) DoLogging(__FILE__,__LINE__,note)
#define LOGMYBUF LOGIT(MyBuf)
--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:[email protected]>
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)
#endif
And on line 123 of "foo.c", you have:
LOGIT("whatever")
If DEBUG is defined, this will expand to:
DoLogging("foo.c",123,"whatever")
as opposed to:
DoLogging("something.h",42,"whatever")
Is this guaranteed?
What about a macro-within-a-macro, as in:
#define LOGIT(note) DoLogging(__FILE__,__LINE__,note)
#define LOGMYBUF LOGIT(MyBuf)
--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:[email protected]>