On Feb 14 20:41, Carlo B. via Cygwin wrote:
> Hello,
> while compiling libsrtp2, I got this error:
>
> /usr/include/machine/types.h:35:8: error: redefinition of ‘struct flock’
> 35 | struct flock {
> | ^~~~~
> In file included from /usr/include/sys/types.h:222,
> from
> ../gstreamer/subprojects/libsrtp-2.7.0/crypto/include/integers.h:60:
> /usr/include/machine/types.h:35:8: note: originally defined here
> 35 | struct flock {
> | ^~~~~
>
> This happens because into the library there is this code:
>
> <--- CUT --->
> #ifdef HAVE_SYS_TYPES_H
> #include <sys/types.h>
> #endif
> #ifdef HAVE_MACHINE_TYPES_H
> #include <machine/types.h>
> #endif
> <--- CUT --->
>
> The first inclusion of "sys/types.h" includes also "machine/types.h"
> and this is ok.
> Next, the second directive includes again "machine/types.h" and here
> it generates the error.
Directly including machine/types.h is wrong. This is a header meant
to be only included via sys/types.h. It contains this test at the
start of the file:
#ifndef _SYS_TYPES_H
#error "must be included via <sys/types.h>"
#endif /* !_SYS_TYPES_H */
Check this against the files in /usr/include/bits from GLibc.
Many of those files are not guarded against multiple inclusions
either.
Yes, we could guard machine/types.h against multiple inclusion,
but the right thing to do would be to change the above code to
never include machine/types.h.
And if you really think you can't do without, add an #else at least:
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#elif defined(HAVE_MACHINE_TYPES_H)
#include <machine/types.h>
#endif
Corinna
--
Problem reports: https://cygwin.com/problems.html
FAQ: https://cygwin.com/faq/
Documentation: https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple