[Spice-devel] [spice-common 3/5] codegen: Use "" rather than <> for cmdline includes
Christophe Fergeau
cfergeau at redhat.com
Fri Jun 24 08:18:40 UTC 2016
On Fri, Jun 24, 2016 at 03:02:34AM -0400, Frediano Ziglio wrote:
> >
> > On Thu, Jun 23, 2016 at 02:03:45PM +0200, Pavel Grunt wrote:
> > > Hi Christophe,
> > >
> > > they were patches changing spice common includes to use <> instead of "",
> > > so I
> > > would keep it.
> >
> > The generated code is in spice-common/common, so my understanding is
> > that "" should be used there for headers from the spice-common module
> > (see spice-common/common/region.c for example). Headers from other
> > modules (spice-protocol) should use <>.
> > In this case, it's changing #include <common/...> to #include
> > "common/..." (but it would do the wrong thing if we started passing
> > spice-protocol headers on the command line)
> >
> > Christophe
> >
>
> Given that:
> - all .c files in spice-common are in common directory;
> - spice-common is intended to be used only by spice-server and spice-gtk;
> - spice-server and spice-gtk has no common subdirectory;
> the local path is never used for "common/.." include file, that is
> path for local "common/foo.h" is "common/common/foo.h" which will never
> exist. Compiler find the include using the fallback "system" include way
> (same used for <> include).
> However there should be cases where a local include is more suitable
> that is .c files or headers never included by users of spice-common.
> To have more control I could suggest something like
>
> if options.includes:
> for i in options.includes:
> if i[:1] != '<':
> i = '"%s"' % i
> writer.header.writeln('#include %s' % i)
> writer.writeln('#include %s' % i)
>
> so caller of the script can choose the version of include to use.
>
> What about for instance if we want to include a system header?
Given that it's not currently the case, the code generation code is not
moving that much, I would not bother making it more complex. Using ""
instead of <> avoids one inconsistency you mentioned earlier (generated
code using both <common/..> and "common/..."). If we need to add a
system header, it's very likely we'll be able to hardcode it in the
python code rather than as a command line argument. In short, I'd keep
things simple.
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160624/ad642382/attachment.sig>
More information about the Spice-devel
mailing list