[Spice-devel] [PATCH libcacard 3/3] libcacard: add G_BEGIN/END_DECLS

Christophe Fergeau cfergeau at redhat.com
Fri Nov 20 03:29:35 PST 2015


On Thu, Nov 19, 2015 at 01:45:44PM -0500, Marc-André Lureau wrote:
> 
> 
> ----- Original Message -----
> > On Thu, Nov 19, 2015 at 02:18:25PM -0200, Eduardo Lima (Etrunko) wrote:
> > > On 11/19/2015 02:00 PM, Marc-André Lureau wrote:
> > > > 
> > > > 
> > > > ----- Original Message -----
> > > >> On 11/19/2015 10:30 AM, Marc-André Lureau wrote:
> > > >>> If the compiler in use is a C++ compiler, adds extern "C" around the
> > > >>> header.
> > > >>>
> > > >>> Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
> > > >>> ---
> > > >>>  src/libcacard.h | 6 ++++++
> > > >>>  1 file changed, 6 insertions(+)
> > > >>>
> > > >>> diff --git a/src/libcacard.h b/src/libcacard.h
> > > >>> index 0770d13..2b2082e 100644
> > > >>> --- a/src/libcacard.h
> > > >>> +++ b/src/libcacard.h
> > > >>> @@ -5,6 +5,10 @@
> > > >>>  #ifndef LIBCACARD_H
> > > >>>  #define LIBCACARD_H
> > > >>>  
> > > >>> +#include <glib.h>
> > > >>> +
> > > >>
> > > >> I guess this glib.h include shouldn't be here.
> > > > 
> > > > Why? (need more coffee?)
> > > 
> > > Well, it might as well be a convention on the project, but in my opinion
> > > it should only include files from the project itself. For instance, you
> > > don't have a glib.h include in gtk.h
> > 
> > gtk.h does not include glib.h because the G_BEGIN_DECLS/G_END_DECLS
> > macros are not used in gtk.h, but in each individual file included from
> > gtk.h (ie gtkwidget.h and friends).
> > Here a different approach is taken, and G_BEGIN_DECLS/G_END_DECLS are
> > only present in the main include file, which in turn includes the
> > various headers.
> > Given that libcacard.h uses macros from glib headers, it makes sense to
> > me that it directly includes <glib.h>
> > An alternative would be to move the G_BEGIN_DECLS/G_END_DECLS to each
> > individual files, in which case the #include <glib.h> could be moved to
> > each includes as well.
> 
> It's fine by me. Imho, it's enough to have in top-level header because the other files shouldn't be used directly anymore.

I did not mention it, but ACK from me for your initial patch.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20151120/4a2e3e89/attachment.sig>


More information about the Spice-devel mailing list