473,406 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

gcc and command line symbols

AB
Hello All,

I've got code like this...

#ifdef SYMBOL
..
..
..

/* Do stuff */
..
..
..
#endif

I want to define SYMBOL on the command line. Which switch should I use
when compiling with gcc?

May 23 '06 #1
6 2318

AB wrote:
Hello All,

I've got code like this...

#ifdef SYMBOL
.
.
.

/* Do stuff */
.
.
.
#endif

I want to define SYMBOL on the command line. Which switch should I use
when compiling with gcc?


Off-topic, but: -D tends to worrk for most compilers I ever used.

May 23 '06 #2
AB wrote:
Hello All,

I've got code like this...

#ifdef SYMBOL
.
.
.

/* Do stuff */
.
.
.
#endif

I want to define SYMBOL on the command line. Which switch should I use
when compiling with gcc?

man gcc
May 23 '06 #3
"AB" <ab*****@gmail.com> writes:
Hello All,

I've got code like this...

#ifdef SYMBOL
.
.
.

/* Do stuff */
.
.
.
#endif

I want to define SYMBOL on the command line. Which switch should I use
when compiling with gcc?


"info gcc" should give you the gcc documentation on most systems.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 23 '06 #4

"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org...
"AB" <ab*****@gmail.com> writes:
Hello All,

I've got code like this...

#ifdef SYMBOL
.
.
.

/* Do stuff */
.
.
.
#endif

I want to define SYMBOL on the command line. Which switch should I use
when compiling with gcc?
"info gcc" should give you the gcc documentation on most systems.


On some systems, without "man" or "info" you may need to use "gcc -v --help"
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this.

May 23 '06 #5
Keith Thompson <ks***@mib.org> wrote:
# "AB" <ab*****@gmail.com> writes:
# > Hello All,
# >
# > I've got code like this...
# >
# > #ifdef SYMBOL

On the command line include -DSYMBOL to simulate
#define SYMBOL
and -DSYMBOL=VALUE for
#define SYMBOL VALUE

For example,
(cd /tmp
cat >t.c <<':eof'
#include <stdio.h>
int main(int n,char **p) {
#ifdef P
printf("P\n");
#endif
#ifdef Q
printf("Q\n");
#endif
printf("least random number %d\n",R);
return 0;
}
:eof
cc -DP -DR=17 t.c
a.out)

# "info gcc" should give you the gcc documentation on most systems.

Once again wasting more bandwidth not answerring the question then
a simple answer would've provided.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
No pleasure, no rapture, no exquisite sin greater than central air.
May 24 '06 #6
SM Ryan <wy*****@tango-sierra-oscar-foxtrot-tango.fake.org> writes:
[...]
Once again wasting more bandwidth not answerring the question then
a simple answer would've provided.


Somebody else had mentioned "-D" before I posted.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 24 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Arpan | last post by:
Microsoft advises not to pass parameters to the Command object in the Execute statement. Why? Thanks, Arpan
23
by: Mark Dickinson | last post by:
I have a simple 192-line Python script that begins with the line: dummy0 = 47 The script runs in less than 2.5 seconds. The variable dummy0 is never referenced again, directly or indirectly,...
6
by: jsw_nz | last post by:
Helo, my first post here.... I am trying to run an agent application that converts and imports two tables from MS Access into mySql. (Intelligent Converters - Access2mySql) I have run similar...
0
by: Tomi Holger Engdahl | last post by:
I am looking for a solution to add on-line drawing tool to a phpBB discussion board. The idea would be that the users can draw their own simple drawings with the tool and attach them easily as...
8
by: Dawn Minnis | last post by:
Hey guys If I have a program (see codeSnippet1) that I compile to be called test.o Then run it as test.o n n 2 3 4 I want the code to be able to strip out the two characters at the start...
11
by: Ken Varn | last post by:
I want to be able to determine my current line, file, and function in my C# application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___ macros for getting this, but I cannot find a...
8
by: Arun Bhalla | last post by:
Hi, I'm developing an Explorer bar using VS.NET 2003 (C#) on Windows XP. For some time, I've noticed that I don't have filenames and line numbers appearing in my exceptions' stack traces. On...
7
by: mackmelo | last post by:
Hi, I'm trying to create a program that reads these two characters (& and ^) as arguments to a funcion. However since they are part of the operational system characters with special funcions...
1
by: Stefan Bellon | last post by:
Hi all! I'm embedding Python in my own C (or rather Ada, but via the C interface) program. Everything runs fine. But I have a small question regarding command history. Let's take the simplest...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.