Michael C. Toren on Thu, 20 Jun 2002 15:35:45 -0400


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] OT: C question: anyone know what a SunOS box defines?

  • From: "Michael C. Toren" <mct@toren.net>
  • To: plug@lists.phillylinux.org
  • Subject: Re: [PLUG] OT: C question: anyone know what a SunOS box defines?
  • Date: Thu, 20 Jun 2002 15:35:40 -0400
  • User-agent: Mutt/1.2.5i

> I'm trying to build some C/C++ code that makes use of networking.
> So far I've identified 2 differences for this host os: AF_INET6 is not
> defined in the networking header files (grrr...), and SIOCGIFFLAGS 
> (SIOCGIFCONF and SIOCGIFADDR) is in sys/sockio.h (which also happens to be
> available through ioctl.h).

To find SIOCGIFFLAGS and friends, I've done this in the past:

	#include <sys/ioctl.h>

	#ifndef __OpenBSD__
	#include <net/if.h>	/* work around OpenBSD double include bug */
	#endif

	#ifndef SIOCGIFCONF
	#include <sys/sockio.h>	/* Solaris, maybe others? */
	#endif

If you want an #ifdef that will identify Solaris systems, try:

	#if defined (__SVR4) && defined (__sun)

Also:

	gcc -E -dM - < /dev/null

Is useful for seeing what #define's gcc is setting for you on various
architectures.

Good luck,

-mct

P.S., my personal belief is that this is very on-topic for PLUG