Compile error: 'siginfo_t' is not declared using gcc-4.8.2 on RedHat, 6.4

Jonathan Wakely jwakely.gcc@gmail.com
Tue Jan 28 01:51:00 GMT 2014


On 28 January 2014 00:20, John Dubchak wrote:
> On 1/27/14 3:45 PM, Jonathan Wakely wrote:
>>
>>
>> You're adding -E to the link command, that's not going to work. To get
>> the preprocessed output you need to preprocess the source file that's
>> failing to compile, not the object files.
>>
>
> I have preprocessed my main.cpp, which is the only cpp file listed in the
> original error:
>
> In file included from http_server_signals.hpp:12:0,
>                  from http_server.hpp:21,
>                  from http_service_traits.hpp:15,
>                  from main.cpp:14:
> /usr/include/sys/wait.h:155:52: error: ‘siginfo_t’ has not been declared
>  extern int waitid (idtype_t __idtype, __id_t __id, siginfo_t *__infop,
>
> Here is the preprocessed output for the http_server_signals.hpp file:
>
> # 20 "http_server.hpp" 2
>
> # 1 "http_server_signals.hpp" 1
> # 10 "http_server_signals.hpp"
> # 1 "/usr/local/gcc-4.8.2/include/c++/4.8.2/cerrno" 1 3
> # 39 "/usr/local/gcc-4.8.2/include/c++/4.8.2/cerrno" 3
>
> # 40 "/usr/local/gcc-4.8.2/include/c++/4.8.2/cerrno" 3
>
> # 1 "/usr/include/errno.h" 1 3 4
> # 42 "/usr/local/gcc-4.8.2/include/c++/4.8.2/cerrno" 2 3
> # 11 "http_server_signals.hpp" 2
>
> # 1 "/usr/include/sys/wait.h" 1 3 4
> # 29 "/usr/include/sys/wait.h" 3 4
> extern "C" {
> # 102 "/usr/include/sys/wait.h" 3 4
> typedef enum
> {
>   P_ALL,
>   P_PID,
>   P_PGID
> } idtype_t;
> # 116 "/usr/include/sys/wait.h" 3 4
> extern __pid_t wait (void * __stat_loc);
> # 139 "/usr/include/sys/wait.h" 3 4
> extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options);
>
>
> # 1 "/usr/include/bits/siginfo.h" 1 3 4
> # 25 "/usr/include/bits/siginfo.h" 3 4
> # 1 "/usr/include/bits/wordsize.h" 1 3 4
> # 26 "/usr/include/bits/siginfo.h" 2 3 4
> # 144 "/usr/include/sys/wait.h" 2 3 4
> # 155 "/usr/include/sys/wait.h" 3 4
> extern int waitid (idtype_t __idtype, __id_t __id, siginfo_t *__infop,
>      int __options);
>
> struct rusage;
>
> extern __pid_t wait3 (void * __stat_loc, int __options,
>         struct rusage * __usage) throw ();
>
> extern __pid_t wait4 (__pid_t __pid, void * __stat_loc, int __options,
>         struct rusage *__usage) throw ();
>
> }
> # 13 "http_server_signals.hpp" 2
>
>
> static void sig_handler(int sig) {
>  if (sig == 2) {
>   int status = 0;
>   int savedErrno = (*__errno_location ());
>   while (waitpid(-1, &status, 1) > 0)
>    continue;
>   (*__errno_location ()) = savedErrno;
>  } else if (sig == 1) {
>   int status = 0;
>   int savedErrno = (*__errno_location ());
>   while (waitpid(-1, &status, 1) > 0)
>    continue;
>   (*__errno_location ()) = savedErrno;
>  } else if (sig == 15) {
>   int status = 0;
>   int savedErrno = (*__errno_location ());
>   while (waitpid(-1, &status, 1) > 0)
>    continue;
>   (*__errno_location ()) = savedErrno;
>  } else if (sig == 17) {
>   int status = 0;
>   int savedErrno = (*__errno_location ());
>   while (waitpid(-1, &status, 1) > 0)
>    continue;
>   (*__errno_location ()) = savedErrno;
>  }
> }
>
> If I am reading this correctly, the siginfo_t definition is available when
> preprocessed.
>
> Is there anything obvious that I might be missing?

I still think you're not including <signal.h> when you should be. That
could be because some other header defines _SIGNAL_H, which would
prevent <signal.h> from defining anything, including __need_siginfo_t,
so that <bits/siginfo.h> doesn't define it.

Does one of your headers use _SIGNAL_H as an include guard?



More information about the Gcc-help mailing list