Syntax errors with <wait.h> Linux (RH5.0), C++,egcs-2.91.57

James Cownie jcownie@dolphinics.com
Mon Oct 12 07:55:00 GMT 1998


If I try to compile a C++ code with <wait.h> and use any of the WIF
macros, I get syntax errors using egcs-2.91.57 on Red Hat 5.0.

e.g.

---wifst.cxx---
#include <wait.h>

int main (int argc, char ** argv)
{
  if (WIFSTOPPED (argc))
    {
      
    }
}
---

jcownie@pc2: g++ -v wifst.cxx
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.57/specs
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.57/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -Asystem(unix) -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ wifst.cxx /tmp/cci9Sypc.ii
GNU CPP version egcs-2.91.57 19980901 (egcs-1.1 release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/g++
 /usr/local/include
 /usr/local/i686-pc-linux-gnu/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.57/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.57/cc1plus /tmp/cci9Sypc.ii -quiet -dumpbase wifst.cc -version -o /tmp/ccX9oDjg.s
GNU C++ version egcs-2.91.57 19980901 (egcs-1.1 release) (i686-pc-linux-gnu) compiled by GNU C version egcs-2.91.57 19980901 (egcs-1.1 release).
wifst.cxx: In function `int main(int, char **)':
wifst.cxx:5: `argc' undeclared (first use this function)
wifst.cxx:5: (Each undeclared identifier is reported only once
wifst.cxx:5: for each function it appears in.)
wifst.cxx:5: warning: ANSI C++ forbids declaration `__in' with no type

Pre-processing the source shows that the problem is probably in the
__typeof or __extension handling ?
The same code compile OK if the compiler things that it is C, rather
than C++.

Pre-processed source appended for your amusement.

Is this a known problem ?
Is there a patch ?

Enjoy

-- Jim 

James Cownie			<jcownie@dolphinics.com>
Dolphin Interconnect Solutions  +44 117 9071438
http://www.dolphinics.com/toolworks

# 1 "wifst.cxx"
# 1 "/usr/include/wait.h" 1 3
# 1 "/usr/include/sys/wait.h" 1 3
# 1 "/usr/include/features.h" 1 3
# 117 "/usr/include/features.h" 3
# 1 "/usr/include/sys/cdefs.h" 1 3
# 1 "/usr/include/features.h" 1 3
# 222 "/usr/include/features.h" 3
# 22 "/usr/include/sys/cdefs.h" 2 3
# 54 "/usr/include/sys/cdefs.h" 3
# 86 "/usr/include/sys/cdefs.h" 3
# 205 "/usr/include/features.h" 2 3
# 1 "/usr/include/gnu/stubs.h" 1 3
# 219 "/usr/include/features.h" 2 3
# 26 "/usr/include/sys/wait.h" 2 3
extern "C" { 
# 1 "/usr/include/gnu/types.h" 1 3
typedef unsigned char __u_char;
typedef unsigned short __u_short;
typedef unsigned int __u_int;
typedef unsigned long __u_long;
typedef unsigned long long int __u_quad_t;
typedef long long int __quad_t;
# 41 "/usr/include/gnu/types.h" 3
typedef __quad_t *__qaddr_t;
typedef __u_quad_t __dev_t;		 
typedef __u_int __uid_t;		 
typedef __u_int __gid_t;		 
typedef __u_long __ino_t;		 
typedef __u_int __mode_t;		 
typedef __u_int __nlink_t; 		 
typedef long int __off_t;		 
typedef __quad_t __loff_t;		 
typedef int __pid_t;			 
typedef int __ssize_t;			 
typedef struct
  {
    int __val[2];
  } __fsid_t;				 
typedef int __daddr_t;			 
typedef char *__caddr_t;
typedef long int __time_t;
typedef long int __swblk_t;		 

typedef long int __clock_t;
typedef unsigned long int __fd_mask;
typedef struct
  {
    __fd_mask fds_bits[1024  / (8 * sizeof (__fd_mask)) ];
  } __fd_set;
typedef int __key_t;
# 30 "/usr/include/sys/wait.h" 2 3
# 1 "/usr/include/waitflags.h" 1 3
# 34 "/usr/include/sys/wait.h" 2 3
# 71 "/usr/include/sys/wait.h" 3
# 1 "/usr/include/waitstatus.h" 1 3
# 1 "/usr/include/endian.h" 1 3
# 1 "/usr/include/bytesex.h" 1 3
# 34 "/usr/include/endian.h" 2 3
# 60 "/usr/include/waitstatus.h" 2 3
union wait
  {
    int w_status;
    struct
      {
	unsigned int __w_termsig:7;  
	unsigned int __w_coredump:1;  
	unsigned int __w_retcode:8;  
	unsigned int:16;
      } __wait_terminated;
    struct
      {
	unsigned int __w_stopval:8;  
	unsigned int __w_stopsig:8;  
	unsigned int:16;
      } __wait_stopped;
  };
# 82 "/usr/include/sys/wait.h" 2 3
extern __pid_t __wait  (void *   __stat_loc)  ;
extern __pid_t wait  (void *   __stat_loc)  ;
extern __pid_t __waitpid  (__pid_t __pid, int *__stat_loc,
			       int __options)  ;
extern __pid_t waitpid  (__pid_t __pid, int *__stat_loc,
			     int __options)  ;
struct rusage;
extern __pid_t __wait3  (void *   __stat_loc,
			     int __options, struct rusage * __usage)  ;
extern __pid_t wait3  (void *   __stat_loc,
			   int __options, struct rusage * __usage)  ;
struct rusage;
extern __pid_t __wait4  (__pid_t __pid, void *   __stat_loc,
			     int __options, struct rusage *__usage)  ;
extern __pid_t wait4  (__pid_t __pid, void *   __stat_loc,
			   int __options, struct rusage *__usage)  ;
} 
# 1 "/usr/include/wait.h" 2 3
# 1 "wifst.cxx" 2
int main (int argc, char ** argv)
{
  if (((( (__extension__ ({ union { __typeof(  argc  ) __in; int __i; } __u;	__u.__in = (  argc  ); __u.__i; }))  ) & 0xff) == 0x7f)  )
    {
    }
}



More information about the Gcc-bugs mailing list