Re: C macro to find the next power of 2 ?

From: Bruce M. Simpson <bms_at_FreeBSD.org>
Date: Wed, 07 Feb 2007 15:04:15 +0000
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
Received on Wed Feb 07 2007 - 14:33:42 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:05 UTC