Unix Programming - defined but not used messages

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > May 2005 > defined but not used messages





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author defined but not used messages
Pat Ford

2005-05-12, 7:56 am

Hi All;
I have a .h file that defines a bunch of stuff that is common across the 6+
programs that my up my project. I'm compiling with -Wall, and some of the
defines aren't used of some of the programs. How do I get the compiler to
stop giving error
messages like:
~/include/tunnel.h:10: warning `ao_device` defined but not used

I know that I can turn off the -Wall but I like having all the messages,
other then this one.
I've tried the #pragma unused but it still comes up.

Thanks
Pat


David Resnick

2005-05-12, 5:52 pm


Pat Ford wrote:
> Hi All;
> I have a .h file that defines a bunch of stuff that is common across

the 6+
> programs that my up my project. I'm compiling with -Wall, and some of

the
> defines aren't used of some of the programs. How do I get the

compiler to
> stop giving error
> messages like:
> ~/include/tunnel.h:10: warning `ao_device` defined but not used
>
> I know that I can turn off the -Wall but I like having all the

messages,
> other then this one.
> I've tried the #pragma unused but it still comes up.
>
> Thanks
> Pat


It is (usually) a mistake to define something
in a header. Try declaring the object extern in
a header and defining it in exactly one source file.

Or are you defining it "static" in a header (ugh).

-David

Pat Ford

2005-05-12, 5:52 pm


"David Resnick" <lndresnick@gmail.com> wrote in message
news:1115903935.712769.39900@g14g2000cwa.googlegroups.com...
>
> Pat Ford wrote:
> the 6+
> the
> compiler to
> messages,
>
> It is (usually) a mistake to define something
> in a header. Try declaring the object extern in
> a header and defining it in exactly one source file.
>
> Or are you defining it "static" in a header (ugh).
>
> -David
>


I'm defining things that are used in a library used by several programs,
the example of ao_device is a handle that is used by 2 script
engines(virtual machines), a watchdog program, an emergency shutdown
program, and an operator interface program, but not the data gathering
system.
All these programs use a common library (libcomedi_ni) that I wrote. The
functions are grouped by logical connections ( in this case the comedi
interface to a pair of cards).
Pat


David Resnick

2005-05-12, 5:52 pm


Pat Ford wrote:
> I'm defining things that are used in a library used by several

programs,
> the example of ao_device is a handle that is used by 2 script
> engines(virtual machines), a watchdog program, an emergency shutdown
> program, and an operator interface program, but not the data

gathering
> system.
> All these programs use a common library (libcomedi_ni) that I wrote.

The
> functions are grouped by logical connections ( in this case the

comedi
> interface to a pair of cards).
> Pat


Can you produce a small example of what you are doing, as in code
that compiles and shows the problem?

I still say it is usually an error to *define* ANYTHING in a header.
For example, if you want to share a variable amongst source files
the correct thing to have in the header is

extern int my_shared_variable;

And in one of the source files is

int my_shared_variable;

-David

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com