LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 07-11-2006, 01:15 AM   #1
George2
Member
 
Registered: Oct 2003
Posts: 354

Rep: Reputation: 30
how to find the value of a macro?


Hello everyone,


I am wondering what is the easiest and safest way to find the value of a macro? For example, if I,

#define FOO "value1"

The value of FOO I can get is "value1" and if then I,

#undef FOO
#define FOO "value2",

then the value of FOO I can get is "value2".


thanks in advance,
George
 
Old 07-11-2006, 06:14 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
#define creates a permanent, hard-coded value at compile time, not run time.

This means that if you have a test in your code for a value, it will fail at compile time if the value is not there ie.,
Code:
#define VALUE
printf("%s\n,VALUE);
Normally you test a #define with another directive like #ifdef or #ifndef not "regular" C code:
Code:
#ifndef __MYINCLUDE_H_
#define __MYINCLUDE_H_
#include "myinclude.h"
#endif

What are you trying to do?
 
  


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
troff: fatal error: can't find macro file tty-char robinhood1995 Linux - Software 1 10-06-2021 08:16 AM
OO 2.0 and macro LinxNew SUSE / openSUSE 1 02-06-2006 10:24 PM
#defining a macro inside a macro? saravkrish Programming 1 05-24-2005 09:48 PM
write a macro ...? matarodi Linux - Software 2 05-17-2005 10:58 AM
macro linuxanswer Programming 1 11-17-2003 03:58 PM

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

All times are GMT -5. The time now is 04:00 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