Re: compiling multiple source files and static functions
From: David Resnick (dresnick_at_N.o.S.p.A.m.p.l.e.a.s.e.alum.mit.edu)
Date: 01/28/05
- Next message: Jens.Toerring_at_physik.fu-berlin.de: "Re: compiling multiple source files and static functions"
- Previous message: beetle: "compiling multiple source files and static functions"
- In reply to: beetle: "compiling multiple source files and static functions"
- Next in thread: Jens.Toerring_at_physik.fu-berlin.de: "Re: compiling multiple source files and static functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 28 Jan 2005 09:07:39 -0500
beetle wrote:
> Hi,
>
> I'm compiling multiple source files which hold some static
> functions(). The compiler `gcc' won't compile them and spit's errors
> like:
>
> warning: `cmpr' defined but not used
> undefined reference to `cmpr'
>
> What options should I give gcc to make sure that it knows that the
> static functions are used within the same program ?
>
> Thnkx.. a lot.
>
> Beetle.
Um, if it is a static function and not referenced within that source
file than it can't be used (it isn't available to the linker, other
translation units don't know about it). Only way a static function
can normally be used outside its file is if you passed a pointer to it
back via some function, in which case gcc wouldn't gripe. That said,
I think you are looking for the gcc unused attribute:.
#include <stdio.h>
static void dead_func(void) __attribute__ ((unused));
int main(void)
{
puts("hello world");
return 0;
}
static void dead_func(void)
{
puts("I don't get called");
}
Above gets no complaints with -Wall.
-David
- Next message: Jens.Toerring_at_physik.fu-berlin.de: "Re: compiling multiple source files and static functions"
- Previous message: beetle: "compiling multiple source files and static functions"
- In reply to: beetle: "compiling multiple source files and static functions"
- Next in thread: Jens.Toerring_at_physik.fu-berlin.de: "Re: compiling multiple source files and static functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|