Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to override Macros on command line?

1,424 views
Skip to first unread message

Steve

unread,
Jan 28, 2003, 7:32:11 AM1/28/03
to
Is it possible to override a #define in a source file with a gcc macro?

Obviously gcc -DMACRO=Something won't work when it is already defined in the
source file.

I'm trying to avoid patching the source file tree every time a new version is
issued. Unfortunately the #define moves around between files with different
versions. So I'd have to search for the file with the #define before
patching it and that's a little ugly.

Any ideas?
--
Steve

André Pönitz

unread,
Jan 28, 2003, 7:53:23 AM1/28/03
to
Steve <nos...@nospam.demon.co.uk> wrote:
> Is it possible to override a #define in a source file with a gcc macro?

Not without touching the source.

> I'm trying to avoid patching the source file tree every time a new version is
> issued. Unfortunately the #define moves around between files with different
> versions. So I'd have to search for the file with the #define before
> patching it and that's a little ugly.

The #define in the source should be wrapped into something like

#ifndef FOO
#define FOO 2.1
#endif

Then you can use -DFOO=2.3 to "override" it.

Andre'

--
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)

Steve

unread,
Jan 28, 2003, 8:10:07 AM1/28/03
to
On 28 Jan 2003 12:53:23 GMT, André Pönitz <poe...@gmx.net> wrote:

>Steve <nos...@nospam.demon.co.uk> wrote:
>> Is it possible to override a #define in a source file with a gcc macro?
>
>Not without touching the source.
>
>> I'm trying to avoid patching the source file tree every time a new version is
>> issued. Unfortunately the #define moves around between files with different
>> versions. So I'd have to search for the file with the #define before
>> patching it and that's a little ugly.
>
>The #define in the source should be wrapped into something like
>
>#ifndef FOO
>#define FOO 2.1
>#endif
>
>Then you can use -DFOO=2.3 to "override" it.
>
>Andre'

OK - shame. I don't have control of the source, so a bash script it is.
--
Steve

0 new messages