LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 06-25-2004, 07:39 AM   #1
tuxfood
Member
 
Registered: Aug 2003
Location: kerala , India
Distribution: RH9 , FC1 ,
Posts: 141

Rep: Reputation: 15
help with #ifdef #undef etc


hi...

read a prgm with this #ifdef #undef etc ...got some idea but now so clear ....

can anyone hellp me out with this

thnks

tuxfood
 
Old 06-25-2004, 07:45 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
please try to write well defined questions when you post.... what are you after? you're question is far too vague and short...
 
Old 06-29-2004, 08:04 AM   #3
tuxfood
Member
 
Registered: Aug 2003
Location: kerala , India
Distribution: RH9 , FC1 ,
Posts: 141

Original Poster
Rep: Reputation: 15
hi..

sorry but i just need to know when and where to use #ifdef #undef etc..

thnks

tuxfood
 
Old 06-29-2004, 08:12 AM   #4
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
You can use #ifdef (if defined) to conditionally compile features into your application. You can use #ifndef (if not defined) for various things, but it is ofen used as guards in your header so that they do not get included more than once in any single .c/.cpp file. You use #undef to undefine a symbol or macro, and #define to define a symbol or create a macro:

Code:
#ifndef __SOME_HEADER_H__
#define __SOME_HEADER_H__

#ifdef WIN32  // if we are compiling on a Windows system...
#include <windows.h>
#endif

#ifdef DEBUG  // Could possibly pass to compiler using -DDEBUG parameter
#define TRACE(msg)    printf(msg);
#else
#define TRACE(msg)
#endif

#undef SOME_MACRO_OR_CONSTANT_YOU_NO_LONGER_WANT_DEFINED

#endif  // __SOME_HEADER_H__
 
  


Reply



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
ifdef for suse?? nkshirsagar SUSE / openSUSE 2 01-10-2005 11:12 PM
Compiling programmes: How to use #ifdef? asciimonster Linux - General 1 12-13-2004 01:35 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:23 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration