[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#138201: marked as done (cpp: macro expansion inside macro calling)



Your message dated Sun, 29 Dec 2002 14:27:35 +0100
with message-id <15886.63559.122202.747388@gargle.gargle.HOWL>
and subject line Bug#138201: cpp: macro expansion inside macro calling
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at maintonly) by bugs.debian.org; 13 Mar 2002 21:21:29 +0000
>From jrm@autsens.com Wed Mar 13 15:21:29 2002
Return-path: <jrm@autsens.com>
Received: from (adsl-nrp8-C8B73A51.sao.terra.com.br) [200.183.58.81] 
	by master.debian.org with esmtp (Exim 3.12 1 (Debian))
	id 16lGBP-0003oz-00; Wed, 13 Mar 2002 15:21:19 -0600
Received: from mantis.autsens.localnet ([192.168.131.7] ident=mail)
	by adsl-nrp8-C8B73A51.sao.terra.com.br with esmtp (Exim 3.12 #1 (Debian))
	id 16lGBI-0003hR-00
	for <maintonly@bugs.debian.org>; Wed, 13 Mar 2002 21:21:08 +0000
Received: from betoes by mantis.autsens.localnet with local (Exim 3.34 #1 (Debian))
	id 16lGBD-0003zM-00; Wed, 13 Mar 2002 18:21:03 -0300
Date: Wed, 13 Mar 2002 18:21:01 -0300
From: jrm@autsens.com
To: Debian Bug Tracking System <maintonly@bugs.debian.org>
Subject: cpp: macro expansion inside macro calling
Message-ID: <20020313212101.GA15174@mantis.autsens.localnet>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.3.27i
X-Reportbug-Version: 1.43
Sender: Jose Roberto B de A Monteiro <betoes@mantis.autsens.localnet>
X-mail-filter-pl: done
X-BadReturnPath: betoes@mantis.autsens.localnet rewritten as jrm@autsens.com
  using "From" header
Delivered-To: maintonly@bugs.debian.org

Package: cpp
Version: 2:2.95.4-9
Severity: wishlist

For example, if a define two macros:

#define a_bit P4,0x08
#define setbit(port,bit) port ## OUT |= bit

And, considering the following line (source code):

setbit(a_bit);

It will generate an error: "macro `setbit' used with just one arg"

It occurs because a_bit will be expanded after setbit. Ok, it would be
desirable in some situations, but in this case, it may be better if
a_bit would be expanded first.

Please, let me know if I am doing anything wrong, if there is a way to
do something similar to that. Thanks!

-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux mantis 2.2.19 #1 Sat Oct 20 18:09:49 EST 2001 i686
Locale: LANG=pt_BR, LC_CTYPE=pt_BR

Versions of packages cpp depends on:
ii  cpp-2.95                      1:2.95.4-1 The GNU C preprocessor.

---------------------------------------
Received: (at 138201-done) by bugs.debian.org; 29 Dec 2002 13:28:33 +0000
>From doko@cs.tu-berlin.de Sun Dec 29 07:28:32 2002
Return-path: <doko@cs.tu-berlin.de>
Received: from mail.cs.tu-berlin.de [130.149.17.13] (root)
	by master.debian.org with esmtp (Exim 3.12 1 (Debian))
	id 18SdUW-0003Ml-00; Sun, 29 Dec 2002 07:28:32 -0600
Received: from bolero.cs.tu-berlin.de (daemon@bolero.cs.tu-berlin.de [130.149.19.1])
	by mail.cs.tu-berlin.de (8.9.3/8.9.3) with ESMTP id OAA04541;
	Sun, 29 Dec 2002 14:27:35 +0100 (MET)
Received: (from doko@localhost)
	by bolero.cs.tu-berlin.de (8.11.6+Sun/8.9.3) id gBTDRZp22043;
	Sun, 29 Dec 2002 14:27:35 +0100 (MET)
From: Matthias Klose <doko@cs.tu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <15886.63559.122202.747388@gargle.gargle.HOWL>
Date: Sun, 29 Dec 2002 14:27:35 +0100
To: jrm@autsens.com, 138201-done@bugs.debian.org
Subject: Re: Bug#138201: cpp: macro expansion inside macro calling
In-Reply-To: <20020313212101.GA15174@mantis.autsens.localnet>
References: <20020313212101.GA15174@mantis.autsens.localnet>
X-Mailer: VM 7.03 under 21.4 (patch 6) "Common Lisp" XEmacs Lucid
Delivered-To: 138201-done@bugs.debian.org
X-Spam-Status: No, hits=-8.2 required=5.0
	tests=IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES,SPAM_PHRASE_00_01
	version=2.41
X-Spam-Level: 

jrm@autsens.com writes:
> Package: cpp
> Version: 2:2.95.4-9
> Severity: wishlist
> 
> For example, if a define two macros:
> 
> #define a_bit P4,0x08
> #define setbit(port,bit) port ## OUT |= bit
> 
> And, considering the following line (source code):
> 
> setbit(a_bit);
> 
> It will generate an error: "macro `setbit' used with just one arg"
> 
> It occurs because a_bit will be expanded after setbit. Ok, it would be
> desirable in some situations, but in this case, it may be better if
> a_bit would be expanded first.
> 
> Please, let me know if I am doing anything wrong, if there is a way to
> do something similar to that. Thanks!

macro arguments are expanded first.  Should define setbit2 as current 
setbit, and 
 
#define setbit(x) setbit2(x) 
 
will work. Thanks to Neil Booth pointing this out.

The "workaround" suggested is the correct solution:

From: Kalle Olavi Niemitalo <kon@iki.fi>
  #define a_bit P4,0x08
  #define setbit(port,bit) port ## OUT |= bit
  #define setbit1(args) setbit(args)
  
  setbit1(a_bit)



Reply to: