Stringified __LINE__
From: Michael B Allen (mba2000_at_ioplex.com)
Date: 02/28/05
- Previous message: bettervssremoting: "A comparison among VSS Remote Access Tools including SourceOffSite, SourceAnyWhere and VSS Remoting"
- Next in thread: Serve Lau: "Re: Stringified __LINE__"
- Reply: Serve Lau: "Re: Stringified __LINE__"
- Reply: Walter Roberson: "Re: Stringified __LINE__"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 28 Feb 2005 02:38:17 -0500
How does the following work and is it portable?
/*
this uses a little trick to allow __LINE__ to be stringified
*/
#define _STRING_LINE_(s) #s
#define _STRING_LINE2_(s) _STRING_LINE_(s)
#define __LINESTR__ _STRING_LINE2_(__LINE__)
#define __location__ __FILE__ ":" __LINESTR__
Result:
printf("%s", __location__);
becomes:
printf("%s", "t0.c" ":" "27");
and prints:
t0.c:27
Mike
PS: macros found in talloc.h at junkcode.samba.org
- Previous message: bettervssremoting: "A comparison among VSS Remote Access Tools including SourceOffSite, SourceAnyWhere and VSS Remoting"
- Next in thread: Serve Lau: "Re: Stringified __LINE__"
- Reply: Serve Lau: "Re: Stringified __LINE__"
- Reply: Walter Roberson: "Re: Stringified __LINE__"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]