From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18480 invoked by alias); 28 Jul 2005 19:51:14 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 18472 invoked by uid 22791); 28 Jul 2005 19:51:09 -0000 Received: from ctb-mesg6.saix.net (HELO ctb-mesg6.saix.net) (196.25.240.86) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 28 Jul 2005 19:51:09 +0000 Received: from GLEB (tbnb-165-193-208.telkomadsl.co.za [165.165.193.208]) by ctb-mesg6.saix.net (Postfix) with ESMTP id 848712398; Thu, 28 Jul 2005 21:51:03 +0200 (SAST) From: "Gerrit van Niekerk" To: random@bubblescope.net Date: Thu, 28 Jul 2005 19:51:00 -0000 MIME-Version: 1.0 Subject: Re: Single line conditional compiles Reply-To: gerritvn@gpvno.co.za Cc: gcc-help@gcc.gnu.org Message-ID: <42E952C7.8456.1C0177FC@localhost> In-reply-to: <42E902B3.9010907@bubblescope.net> References: <42E91D4D.22097.1B3092F9@localhost> Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-SW-Source: 2005-07/txt/msg00321.txt.bz2 On 28 Jul 2005 at 17:07, random@bubblescope.net wrote: > Gerrit van Niekerk wrote: > > >How can one implement single line conditional compile macros with GCC? > > > >Instead of having: > > > >#ifdef OPT1 > > > >#endif > > > >Having something like: > >IFOPT1 > > > >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 Thanks Chris, This is a workable solution and portable too! Gerrit