LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

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

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 :

Code:
#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:

Code:
#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"));
                                                                                                  
  TRACE;
                                                                                                  
return 0;
}
When I compile it I get this:

Code:
[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
Strike
Member
 
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
AMMullan
Member
 
Registered: Sep 2003
Location: United Kingdom
Distribution: Ubuntu, Arch
Posts: 437

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

 
  


Reply


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


All times are GMT -5. The time now is 03:13 AM.

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