Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Jan 2011 00:23:10 -0800
From:      Julian Elischer <julian@freebsd.org>
To:        Roman Divacky <rdivacky@freebsd.org>
Cc:        Alexander Best <arundel@freebsd.org>, freebsd-hackers@freebsd.org
Subject:   Re: empty function macros
Message-ID:  <4D46716E.6070500@freebsd.org>
In-Reply-To: <20110131075439.GA49765@freebsd.org>
References:  <20110130172941.GA10701@freebsd.org> <20110131075439.GA49765@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 1/30/11 11:54 PM, Roman Divacky wrote:
> no problem with this with clang :)
>
> On Sun, Jan 30, 2011 at 05:29:41PM +0000, Alexander Best wrote:
>> hi there,
>>
>> i noticed freebsd has a few of the following macros:
>>
>> #define FUNC(sb)
>>
>> when you do something like
>>
>> if (cond)
>>      FUNC(i)

you missed an important part....

it's probably
  if (cond)
     FUNC(i);
   (note the ';')
THAT would be ok....
  without the ';' you just made whatever comes next conditional.

>> the compiler complains about an if statement with an empty body. any sensible
>> way of dealing with this issue?
>>
>> i saw some reiserfs code which does the following to silence compilers:
>>
>> #define FUNC(sb) do { } while (0)

yeah we do that too in some places.
(certainly at work I have done so)


>> cheers.
>> alex
>>
>> -- 
>> a13x
>> _______________________________________________
>> freebsd-hackers@freebsd.org mailing list
>> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
>> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
>




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4D46716E.6070500>