This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Problem including certain C header files in C++ programs (net/if. h and sys/stat.h in particular) [additional information]


Some additional information, it is looking like it is a WindRiver thing
after all...

A simple test program:

#ifdef DIGLINUX
#       include <sys/types.h>
#       include <sys/stat.h>
#       include <unistd.h>
#else
#       include <vxWorks.h>
#       include <stat.h>
#endif


class foo
{
public:
        void sendData(void);
};

void foo::sendData(void)
{
    struct stat stbuf;
    if (stat("/etc/motd", &stbuf) < 0)
    {
        return;
    }
}

Compiler options:
 -Wall -Wshadow -ansi

Building for VxWorks gives the warning, building with -DDIGLINUX defined for
Redhat 8.0 (gcc 3.2) or Solaris8/Sparc (either 2.95 or 3.2.1) builds clean.
Using WindRiver's provided GCC without their includes (IE, omitting a -I to
their directory hierarchy) builds cleanly without warnings.  Looking at
a diff of -E output for building both with and without -I with their
compiler, the only diffences are # line directives (# number "file" stuff),
with the "stuff" being 0 or more numbers.  With the -I, I get fewer numbers
than without, and otherwise there are no differences in the -E outputs.
(example: without -I gives # 1 "/path/file.h" 2 3 4; with gives # 1
"/path/file.h" 2), both paths are identical.

Looking at the structure definitions in the two places, appear similar.
Looking at the function prototype, they are essentially the same.

The one thing I don't really understand is why

struct stat
{
...
}

extern int stat(char *foo, struct stat s)

would be assumed as the constructor, since it is extern int stat(), NOT
extern int stat::stat().

Go figure.

	Dave

I'll call WindRiver in the morning.

-----Original Message-----
From: Dave Gotwisner 
Sent: Thursday, June 19, 2003 5:12 PM
To: GCC Help mailing list (E-mail)
Subject: Problem including certain C header files in C++ programs
(net/if. h and sys/stat.h in particular)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]