timer_create refers to struct sigevent; struct sigevent not availabe unders same conditions as timer_create

timer_create refers to struct sigevent; struct sigevent not availabe unders same conditions as timer_create

Post by mshet » Fri, 17 Sep 2004 12:47:51



Him

time.h in included in c source file. The file does not use the
timer_create function but compiling the file throws a warning:

/opt/WS6U2/SUNWspro/bin/cc semaph.c -D_XPG4_2
"/usr/include/time.h", line 99: warning: dubious tag declaration:
struct sigevent

This is because the declaration of timer_create function gets included
which refers to the structure sigevent. But the structure sigevent
present in sys/siginfo.h included in time.h does not get included as
it is enclosed in a
!defined(_XPG4_2).

Basically the condition under which the declaration of timer_create
gets included and sigevent gets included vary.

time.h
--------------------------------------------------------------------------
#if defined(__EXTENSIONS__) || ((__STDC__ - 0 == 0) && \
                !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE))
|| \
                (_POSIX_C_SOURCE > 2)
extern int timer_create(clockid_t, struct sigevent *, timer_t *);
#endif
--------------------------------------------------------------------------

sys/siginfo.h
--------------------------------------------------------------------------
#if (!defined(_POSIX_C_SOURCE) && !defined(_XPG4_2)) || \
        (_POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__)

struct sigevent {
        int             sigev_notify;   /* notification mode */
        union {
                int     _sigev_signo;   /* signal number */
                void    (*_sigev_notify_function)(union sigval);
        } _sigev_un;
        union sigval    sigev_value;    /* signal value */
        int             _sigev_pad1;
        void            *_sigev_notify_attributes;
        int             _sigev_pad2;

Quote:};

#endif
--------------------------------------------------------------------------

Is there a way to resolve this warning? Should it be resolved since I
am not using timer_create. Should _XOPEN_SOURCE be defined when
_XPG4_2 is defined?. If I define _XOPEN_SOURCE as well this warning
goes off but I am not sure if I am doing the right thing?

Kindly help.

Thanks and Regards,
Mranalini

PS: I am working on Solaris 2.6 and using the Forte 6 Update 2 cc
compiler.

 
 
 

timer_create refers to struct sigevent; struct sigevent not availabe unders same conditions as timer_create

Post by Jonathan Ada » Fri, 17 Sep 2004 20:46:00



> Him

> time.h in included in c source file. The file does not use the
> timer_create function but compiling the file throws a warning:

> /opt/WS6U2/SUNWspro/bin/cc semaph.c -D_XPG4_2
> "/usr/include/time.h", line 99: warning: dubious tag declaration:
> struct sigevent

_XPG4_2 should never be directly defined by you.  See standards(5) for
directions on which defines are needed for the various standards
Solaris supports.  The Solaris 2.6 version of this is:

http://docs.sun.com/db/doc/802-5747-05/6i9g1c3j6?a=view

And it says:

XPG4v2     The application must define _XOPEN_SOURCE and set
_XOPEN_SOURCE_EXTENDED=1.

So you want -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1  for XPG4v2
compliance (assuming that's what you want).

- jonathan