Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 07 Feb 2007 15:04:15 +0000
From:      "Bruce M. Simpson" <bms@FreeBSD.org>
To:        Luigi Rizzo <rizzo@icir.org>
Cc:        Attilio Rao <attilio@freebsd.org>, Stefan Bethke <stb@lassitu.de>, current@freebsd.org
Subject:   Re: C macro to find the next power of 2 ?
Message-ID:  <45C9EA6F.1080503@FreeBSD.org>
In-Reply-To: <20070207025916.A63989@xorpc.icir.org>
References:  <20070207004131.A62183@xorpc.icir.org>	<15241.SV0BLFJbGwk=.1170843949.squirrel@koef.zs64.net>	<20070207024918.D63529@xorpc.icir.org>	<3bbf2fe10702070255q58ab6c9fn2b393cfbc75a3fb@mail.gmail.com> <20070207025916.A63989@xorpc.icir.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Luigi Rizzo wrote:
>> You cannot use this unless you don't rewrite as a preprocessing stub.
>>     
>
> that's why i am using my version and wrote it functionally.
>   

All this talk of recursively evaluated CPP macros is making my head spin.

We just want to compute LOG2(sizeof(struct foobar))+1 after all.

Ooh, but many tried and died:
    http://swtch.com/gosling89ace.pdf
 http://groups.google.co.uk/group/comp.lang.c/browse_thread/thread/f34a65d3fe73a6d4/0d3322283427a51a?lnk=st&q=For+loop+equivalent+with+the+preprocessor&rnum=2&hl=en#0d3322283427a51a 

Go to the end of this thread, and it turns out C++ can *probably* do it 
through templatization.

http://groups.google.co.uk/group/comp.lang.c/browse_thread/thread/95bfa768423adb4f/17eb99dbdf11d161?lnk=st&q=log2+preprocessor&rnum=1&hl=en#17eb99dbdf11d161

Good luck with that...

Regards,
BMS





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?45C9EA6F.1080503>