__LINE__ and affiliates

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

__LINE__ and affiliates

1,360 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Brinkand on Thu Oct 07 02:25:16 MST 2010
I would like to be able to add code line number and build dates into my debug output, which I output on the UART of an LPC111x using sprintf.

I included __LINE__ and __TIMESTAMP__ in sprintf arguments and #warning, but they are not recognized.

sprintf(UART_string,"Example: __TIMESTAMP__ __LINE__ \r\n");
Are they available and how do I activate them?

Are there alternative ways to get release time stamp into debug information?
0 Kudos
Reply
5 Replies

1,349 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by renan on Thu Oct 07 04:34:09 MST 2010

Quote: CodeRedSupport

The following article might be helpful too:
http://www.decompile.com/cpp/faq/file_and_line_error_string.htm



The following article is helpful.

Renan
0 Kudos
Reply

1,349 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Thu Oct 07 03:48:09 MST 2010
You could also use simple concatenation (and thus remove the need to sprintf)
UART_string = "Example: " _TIMESTAMP__ " " __LINE__ "\r\n" ;
0 Kudos
Reply

1,349 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Brinkand on Thu Oct 07 03:00:39 MST 2010
Terrific! Thanks.
0 Kudos
Reply

1,349 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Oct 07 02:40:22 MST 2010
I've used:

printf("LPC11C14-CAN Version 1.0 "__DATE__" "__TIME__"\n\r");
0 Kudos
Reply

1,349 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Thu Oct 07 02:34:11 MST 2010
Try changing to something like:

sprintf(UART_string,"Example: %s %s  \r\n", __TIMESTAMP__,__LINE__ );
The following article might be helpful too:

http://www.decompile.com/cpp/faq/file_and_line_error_string.htm

Regards,
CodeRedSupport
0 Kudos
Reply