public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: random@bubblescope.net
To: gerritvn@gpvno.co.za
Cc: gcc-help@gcc.gnu.org
Subject: Re: Single line conditional compiles
Date: Thu, 28 Jul 2005 16:08:00 -0000	[thread overview]
Message-ID: <42E902B3.9010907@bubblescope.net> (raw)
In-Reply-To: <42E91D4D.22097.1B3092F9@localhost>

Gerrit van Niekerk wrote:

>How can one implement single line conditional compile macros with GCC? 
>
>Instead of having:
>
>#ifdef OPT1
><valid C line>
>#endif
>
>Having something like:
>IFOPT1 <valid C line>
>
>The following works with BorlandC, but not GCC:
>
>#ifdef OPT1
>#define IFOPT1
>#else
>#define IFOPT1 /##/
>#endif
>
>I understand why it does not work - I am looking for a solution, not an 
>explanation :)
>
>  
>
Not quite what you are looking for, but how about?

#ifdef OPT1
#define IFOPT1(x) x
#else
#define IFOPT1(x)
#endif

Then you write
IFOPT1(stuff)

This has the advantage you can write it mid-line, with stuff before and
after it.

Chris

  reply	other threads:[~2005-07-28 16:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-28 16:02 Gerrit van Niekerk
2005-07-28 16:08 ` random [this message]
2005-07-28 19:51   ` Gerrit van Niekerk
2005-07-28 16:16 ` Eljay Love-Jensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42E902B3.9010907@bubblescope.net \
    --to=random@bubblescope.net \
    --cc=gcc-help@gcc.gnu.org \
    --cc=gerritvn@gpvno.co.za \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).