From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12261 invoked by alias); 28 Jul 2005 16:08:54 -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 12247 invoked by uid 22791); 28 Jul 2005 16:08:50 -0000 Received: from mailgw.cs.york.ac.uk (HELO mailgw.cs.york.ac.uk) (144.32.40.3) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 28 Jul 2005 16:08:50 +0000 Received: from minster.cs.york.ac.uk ([144.32.40.2]) by mailgw.cs.york.ac.uk with esmtps (TLSv1:AES256-SHA:256) (Exim 4.44) id 1DyAum-0000ba-AN; Thu, 28 Jul 2005 17:07:20 +0100 Received: from bushfire.cs.york.ac.uk ([144.32.40.24] helo=[192.168.112.229]) by minster.cs.york.ac.uk with esmtp (Exim 4.44) id 1DyAum-0006s8-EQ; Thu, 28 Jul 2005 17:07:20 +0100 Message-ID: <42E902B3.9010907@bubblescope.net> Date: Thu, 28 Jul 2005 16:08:00 -0000 From: random@bubblescope.net User-Agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716) MIME-Version: 1.0 To: gerritvn@gpvno.co.za CC: gcc-help@gcc.gnu.org Subject: Re: Single line conditional compiles References: <42E91D4D.22097.1B3092F9@localhost> In-Reply-To: <42E91D4D.22097.1B3092F9@localhost> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2005-07/txt/msg00315.txt.bz2 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