After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 780923 - Various combined-flag #defines are not C++ friendly
Various combined-flag #defines are not C++ friendly
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal normal
: 1.11.90
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-04-05 11:09 UTC by Sebastian Dröge (slomo)
Modified: 2017-04-05 11:46 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Sebastian Dröge (slomo) 2017-04-05 11:09:02 UTC
In core, the following at least. A C++ compiler will complain that the result of the |-combination is not part of the enum (correctly!). Some other cases of such #defines are explicitly casting to the target type because of that (e.g. GST_BUFFER_COPY_ALL).

I would suggest to do the same for the other ones (and we should also check -base and -bad libs).


gst/gstpad.c:#define _PAD_PROBE_TYPE_ALL_BOTH_AND_FLUSH (GST_PAD_PROBE_TYPE_ALL_BOTH | GST_PAD_PROBE_TYPE_EVENT_FLUSH)

gst/gstminiobject.h:#define GST_LOCK_FLAG_READWRITE  (GST_LOCK_FLAG_READ | GST_LOCK_FLAG_WRITE)

gst/gstmemory.h:#define GST_MAP_READWRITE      (GST_MAP_READ | GST_MAP_WRITE)

gst/gstbuffer.h:#define GST_BUFFER_COPY_METADATA       (GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS |\

gst/gstelementfactory.h:#define GST_ELEMENT_FACTORY_TYPE_VIDEO_ENCODER (GST_ELEMENT_FACTORY_TYPE_ENCODER | GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO | GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE)
gst/gstelementfactory.h:#define GST_ELEMENT_FACTORY_TYPE_AUDIO_ENCODER (GST_ELEMENT_FACTORY_TYPE_ENCODER | GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO)
gst/gstelementfactory.h:#define GST_ELEMENT_FACTORY_TYPE_AUDIOVIDEO_SINKS (GST_ELEMENT_FACTORY_TYPE_SINK | GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO | GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO | GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE)
Comment 1 Sebastian Dröge (slomo) 2017-04-05 11:10:26 UTC
Any opinions?
Comment 2 Sebastian Dröge (slomo) 2017-04-05 11:46:30 UTC
Seeing that we already do that elsewhere, I just went ahead with it:

commit 42a8ffcd39e0f39d94c950d377b1482b5fb145ec
Author: Sebastian Dröge <sebastian@centricular.com>
Date:   Wed Apr 5 14:45:00 2017 +0300

    gst: Cast combined-flags constants to their respective target types
    
    This makes C++ compilers a bit more happy without having the user of the
    constants cast. It also provides the correct type information to GI.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780923