Problem including certain C header files in C++ programs (net/if. h and sys/stat.h in particular)
Dave Gotwisner
Dave.Gotwisner@harmonicinc.com
Fri Jun 20 00:13:00 GMT 2003
I am trying to build a C++ program (using G++) that includes both net/if.h
and sys/stat.h. When I compile my program,
I get several warnings which report as many lines of includes plus the
warning. I would like to be able to turn off the
warnings around the header files (I assume this is with a #pragma).
I want to keep a fairly high level of warnings enabled under normal use. Is
there a way to do what I want?
The compiler options being used (for warnings) are: -Wall -Wshadow -ansi.
The warning received for net/if.h is: warning: `int ifconf (int, char *)'
hides constructor for `struct ifconf'.
Looking at the header file, the structure is defined as:
struct ifconf {
int ifc_len;
...
};
and the line that causes the problem is:
extern int ifconf(int, caddr_t);
The code is correctly contained in extern "C" {...} for the C++.
The platform/target being used here is Sparc-Solaris8 / VxWorks-simulator
(or VxWorks-mips). These structures look consistent with what
I am used to for Linux / BSD, so I doubt it is a VxWorks-ism (and their
support for C++ is poor to be polite).
My understanding of the way C++ works is that a constructor for a class
ifconf should be declared ifconf::ifconf(), NOT ifconf(), so I don't really
see why this is even being reported.
Compiler versions used 2.96 for the simulator and for mips.
Thanks in advance,
Dave Gotwisner
More information about the Gcc-help
mailing list