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

Kieran Bingham kieran.bingham at ideasonboard.com
Mon Jan 7 18:10:54 CET 2019


Hi Laurent,

On 07/01/2019 16:27, Laurent Pinchart wrote:
> 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).

I agree. I've sent an updated patch.



> 
>>  namespace libcamera {
>>
>>  class MediaDevice;
> 

-- 
Regards
--
Kieran


More information about the libcamera-devel mailing list