Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12453 Discussions

Compiler not detecting unused functions

Honored Contributor II

I recently inherited a project and I am trying to clean it up. I have the following warnings enabled but I don't think the unused functions are being detected or at least reported by the compiler.  


-Wall -Wunused -Wunused-function -Wextra 



Here's a the build command for one of the source files 


nios2-elf-gcc -xc -MP -MMD -c -I../gsi_proc_bsp//HAL/inc -I../gsi_proc_bsp/ -I../gsi_proc_bsp//drivers/inc -DSYSTEM_BUS_WIDTH=32 -pipe -D__hal__ -DALT_NO_C_PLUS_PLUS -DALT_NO_CLEAN_EXIT -D'exit(a)=_exit(a)' -DALT_NO_EXIT -DALT_NO_INSTRUCTION_EMULATION -DALT_STACK_CHECK -fstack-check -DALT_SINGLE_THREADED -DALTERA_AVALON_UART_USE_IOCTL -O1 -g -Wall -Wunused -Wunused-function -Wextra -mhw-div -mcustom-fpu-cfg=60-1 -mhw-mul -mno-hw-mulx -o obj/default/.metadata/.plugins/org.eclipse.cdt.make.core/specs.o .metadata/.plugins/org.eclipse.cdt.make.core/specs.c 




I just to test the compiler flag I added the following function, and the compiler detects the unused variable, but not the unused function! 


void MyUnusedFunction(void) { int i; printf("I do nothing\n"); }  

Any ideas?
0 Kudos
2 Replies
Honored Contributor II

Because your function is not defined as static void it could be used in other files. Since the compiler looks at only one file at a time it has no way of knowing if this is the case.

Honored Contributor II

Thanks, the fun of a different compiler.