[libcamera-devel] [PATCH] libcamera: media_object: Undef major/minor system macros

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Jan 7 17:27:58 CET 2019


Hi Kieran,

Thank you for the patch.

On Monday, 7 January 2019 17:54:27 EET Kieran Bingham wrote:
> GCC 7.3.0 defines conflicting macros within <sys/types.h> which are
> deprecated and removed in later versions.
> 
> To support compilation with this toolchain, ensure that any previous
> definition is removed before the class definitions.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> ---
>  src/libcamera/include/media_object.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/src/libcamera/include/media_object.h
> b/src/libcamera/include/media_object.h index 950a33286690..00772fd11234
> 100644
> --- a/src/libcamera/include/media_object.h
> +++ b/src/libcamera/include/media_object.h
> @@ -12,6 +12,15 @@
> 
>  #include <linux/media.h>
> 
> +/*
> + * In the GNU C Library, "major" and "minor" are defined by
> <sys/sysmacros.h>. + * GCC 7.3.0 also defines this in <sys/types.h> for
> historical compatibility. + * To prevent conflicting with the major() and
> minor() member functions we + * unconditionally undef these here.
> + */
> +#undef major
> +#undef minor

I don't think we should do this, as it would prevent users of media_object.h 
from using the glibc macros (or at least interfere with their usage, 
potentially creating more problems). Let's instead rename the two conflicting 
functions, to deviceMinor() and deviceMajor() (or other similar names).

>  namespace libcamera {
> 
>  class MediaDevice;

-- 
Regards,

Laurent Pinchart





More information about the libcamera-devel mailing list