C macro to find the next power of 2 ?
Bruce M. Simpson
bms at FreeBSD.org
Wed Feb 7 15:33:42 UTC 2007
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
More information about the freebsd-current
mailing list