- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, the fun of a different compiler.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page