我有一个带有循环的函数,我将在 C++ 代码中得到循环的扩展开发。我还有一个递归函数,我想得到相同的。
我需要的例子:
for (i = 0; i <4; i++)
{
printf ("%d", "example");
}
应该是我需要的结果
printf ("%d", "example");
printf ("%d", "example");
printf ("%d", "example");
printf ("%d", "example");
这是一个简单的例子。但是我需要为更复杂的功能执行此操作。
对于它的值(value),我使用 visual c++
。
我不知道是否有构建选项。
最佳答案
如果您使用 GCC 来编译您的代码,那么您可以使用 -funroll-loop
选项来取消循环。
- -funroll-loops
Unroll loops whose number of iterations can be determined at compile time or upon entry to the loop. -funroll-loops implies -frerun-cse-after-loop. This option makes code larger, and may or may not make it run faster.
还有另一个(类似的)选项:
- -funroll-all-loops
Unroll all loops, even if their number of iterations is uncertain when the loop is entered. This usually makes programs run more slowly. -funroll-all-loops implies the same options as -funroll-loops,
关于c++ - 如何将编译扩展到函数或循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13381649/