Altera_Forum
Honored Contributor
21 years agoSmall C Lib
I was generating a small project in the IDE to give some benchmarks on code size for different compiler/linker options. The program was the hello_world + the following:
double x, y, z; printf("Hello from Nios II!\n"); x = 1.2; y = 3.5; z = x + y; printf("x+y = %.02lf\n", z); z = x - y; printf("x-y = %.02lf\n", z); z = x * y; printf("x*y = %.02lf\n", z); z = x / y; printf("x/y = %.02lf\n", z); When all was compiled and linked with default options, the size was 61K. So I turned on the Small C and reduce driver options in the system, and the code dropped to a waluping 18K! It looked supicious, so I looked up what you lose in the Small C. Floating point is not supported in printf. Hum! Why didn't the compiler/linker warn me. There were no errors or warnings with the above code + Small C options. What exactly did the compiler generate? Don't have a target to load it to yet, so I can't see what was generated. Just curious. I am dissapointed that I was not warned about the no support of floating point in the printf. How many other things are hidden that we are not being warned about? Thoughts.... Rick