Q:

how to get the compiled extended to a function or loop

I have a function with a loop that I would get the extended development of the loop in c++ code. Also I have a recursive function that I wanted to get the same.
An example of I need:
for (i = 0; i <4; i++)
{
      printf ("%d", "example");
}

should result that i need
printf ("%d", "example");
printf ("%d", "example");
printf ("%d", "example");
printf ("%d", "example");

this is a simple example. But I would need to do this for more complex functions.
For what it's worth I use visual c++.
I do not know if there is a build option for this. 

A:

If you're using GCC to compile your code, then you can use -funroll-loop option to unloop this loop.
The documentation says,

-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. 

There is another (similar) option:

-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, 

A:

Visual C++ does not have an explicit option for loop unrolling. However, if you turn optimisations on, then the optimiser loop unrolls based on heuristic. Loop unrolling is a trade-off - it may or may not result in improved performance.
Here is a discussion on loop unrolling in Visual C++.

