By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,423 Members | 1,327 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,423 IT Pros & Developers. It's quick & easy.

"FOR" in preprocessor macro

P: n/a
would it be possible to sort of engineer some sort of preprocessor macro
that does a 'for' loop.
i.e. for where you would normally use a normal for loop, but when it is
known ay compile time whay the variable is, hence unrolling the loop.
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
songie D wrote:
would it be possible to sort of engineer some sort of preprocessor
macro that does a 'for' loop.
i.e. for where you would normally use a normal for loop, but when it
is known ay compile time whay the variable is, hence unrolling the
loop.


http://www.boost.org/libs/preprocessor/doc/index.html

-cd
Nov 17 '05 #2

P: n/a
Carl Daniel [VC++ MVP] wrote:
songie D wrote:
would it be possible to sort of engineer some sort of preprocessor
macro that does a 'for' loop.
i.e. for where you would normally use a normal for loop, but when it
is known ay compile time whay the variable is, hence unrolling the
loop.


http://www.boost.org/libs/preprocessor/doc/index.html


Doesn't VC already do this with a normal for-loop when optimising for speed,
the number of iterations can be determined at compile time, and the amount
of inserted code is reasonable small?

I'm certain I've come across a compiler that did that, but I can't remember
for certain if VC does it though...

--
Sven Groot

http://unforgiven.bloghorn.com

Nov 17 '05 #3

P: n/a
Sven Groot wrote:
Carl Daniel [VC++ MVP] wrote:
songie D wrote:
would it be possible to sort of engineer some sort of preprocessor
macro that does a 'for' loop.
i.e. for where you would normally use a normal for loop, but when it
is known ay compile time whay the variable is, hence unrolling the
loop.


http://www.boost.org/libs/preprocessor/doc/index.html


Doesn't VC already do this with a normal for-loop when optimising for
speed, the number of iterations can be determined at compile time,
and the amount of inserted code is reasonable small?

I'm certain I've come across a compiler that did that, but I can't
remember for certain if VC does it though...


I'm not sure if VC does automatic loop unrolling, but there definitely are
compilers that do so.

-cd
Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.