Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-13-2004, 12:48 PM   #1
Registered: Sep 2003
Location: United Kingdom
Distribution: Ubuntu, Arch
Posts: 438

Rep: Reputation: 30
Debugging Issue

I'm learning C programming ( ) and i've found that a macro that apprently is very good doesn't work - hmmm me thinks this ain't THAT good :P

The macro is :

#define TRACE printf("%s @ %u\n",_ _FILE_ _,_ _LINE_ _)
i've got it set in a test app so you can see how I've used it:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define TRACE printf("%s @ %u\n",_ _FILE_ _,_ _LINE_ _)
int main(int argc, char *argv[], char *envp[]) {
  printf("You $HOME variable is: %s\n\n", getenv("HOME"));
return 0;
When I compile it I get this:

[ammullan@darkside Programming]$ gcc -o a -Wall a.c
a.c: In function `main':
a.c:10: `_' undeclared (first use in this function)
a.c:10: (Each undeclared identifier is reported only once
a.c:10: for each function it appears in.)
a.c:10: parse error before "_FILE_"
[ammullan@darkside Programming]$
Any ideas? As far as I can see the code's fine.....
Old 01-13-2004, 01:28 PM   #2
Registered: Jun 2001
Location: Houston, TX, USA
Distribution: Debian
Posts: 569

Rep: Reputation: 31
Are you sure that's not supposed to be __FILE__, and __LINE__ ? (note the lack of spaces between underscores)
Old 01-13-2004, 02:04 PM   #3
Registered: Sep 2003
Location: United Kingdom
Distribution: Ubuntu, Arch
Posts: 438

Original Poster
Rep: Reputation: 30
Hahahaha yup it is, tried it and worked fine...

I'm reading a SAMS book "Teach yourself Linux Programming" and it's been great so far but think i'm definately gonna go buy "The C Programming Language" now (written by authors of C so can't go wrong.

Thanks Strike



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Debugging Mercurius Programming 3 10-19-2005 02:59 PM
Visual Debugging and Linux Kernel Debugging Igor007 Programming 0 09-30-2005 10:33 AM
Debugging ISR eshwar_ind Programming 1 06-18-2005 04:31 PM
Debugging Evgeny Linux - Networking 1 02-15-2005 01:32 PM
debugging devit Programming 1 02-10-2004 11:49 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:11 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration