[ovs-dev] [PATCH 10/11] lib: Avoid using C++ keywords as variable names

Ben Pfaff blp at nicira.com
Wed Nov 12 18:20:58 UTC 2014


Thanks for confirming.

I expanded the commit message slightly to the following and applied
this:

    lib: Avoid using C++ keywords as variable names in header files.

    Otherwise C++ programs can't #include the headers.

    Signed-off-by: Amit Bose <bose at noironetworks.com>
    Signed-off-by: Ben Pfaff <blp at nicira.com>

On Wed, Nov 12, 2014 at 10:12:28AM -0800, Amit Bose wrote:
> Yes, Ben is correct.
> 
> Some background: the intention is to build a C++ program that includes some
> OVS header files and links against the OVS library. Including the
> header dynamic-string.h
> results in compilation errors. The library is still being built with C
> using the usual OVS build process, so it is really not necessary to change
> dynamic-string.c till someone tries to build the entire OVS code-base using
> C++.
> 
> On Wed, Nov 12, 2014 at 9:59 AM, Ben Pfaff <blp at nicira.com> wrote:
> 
> > On Wed, Nov 12, 2014 at 03:55:00PM -0200, Flavio Leitner wrote:
> > > On Wed, Nov 12, 2014 at 03:06:08PM +0100, Thomas Graf wrote:
> > > > From: Amit Bose <bose at noironetworks.com>
> > >
> > > It would be nice to have some description to what this is
> > > trying to solve. Is there a real problem being fixed here?
> > >
> > > > Signed-off-by: Amit Bose <bose at noironetworks.com>
> > > > ---
> > > >  AUTHORS              | 1 +
> > > >  lib/dynamic-string.h | 4 ++--
> > > >  2 files changed, 3 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/AUTHORS b/AUTHORS
> > > > index b5ac696..84fca3a 100644
> > > > --- a/AUTHORS
> > > > +++ b/AUTHORS
> > > > @@ -8,6 +8,7 @@ Alexey I. Froloff       raorn at altlinux.org
> > > >  Alex Wang               alexw at nicira.com
> > > >  Alfredo Finelli         alf at computationes.de
> > > >  Alin Serdean            aserdean at cloudbasesolutions.com
> > > > +Amit Bose               bose at noironetworks.com
> > > >  Andrew Evans            aevans at nicira.com
> > > >  Andrew Lambeth          wal at nicira.com
> > > >  Andy Hill               hillad at gmail.com
> > > > diff --git a/lib/dynamic-string.h b/lib/dynamic-string.h
> > > > index 2272343..396a24e 100644
> > > > --- a/lib/dynamic-string.h
> > > > +++ b/lib/dynamic-string.h
> > > > @@ -61,9 +61,9 @@ int ds_get_line(struct ds *, FILE *);
> > > >  int ds_get_preprocessed_line(struct ds *, FILE *, int *line_number);
> > > >  int ds_get_test_line(struct ds *, FILE *);
> > > >
> > > > -void ds_put_strftime_msec(struct ds *, const char *template, long
> > long int when,
> > > > +void ds_put_strftime_msec(struct ds *, const char *format, long long
> > int when,
> > > >                       bool utc);
> > >
> > > What about the function itself in lib/dynamic-string.c:
> > >
> > > 187 /* Writes the current time with optional millisecond resolution to
> > 'string'
> > > 188  * based on 'template'.
> > > 189  * The current time is either localtime or UTC based on 'utc'. */
> > > 190 void
> > > 191 ds_put_strftime_msec(struct ds *ds, const char *template, long long
> > int when,
> > > 192                      bool utc)
> > > 193 {
> > >
> > >
> > > > -char *xastrftime_msec(const char *template, long long int when, bool
> > utc);
> > > > +char *xastrftime_msec(const char *format, long long int when, bool
> > utc);
> > >
> > > 187 /* Writes the current time with optional millisecond resolution to
> > 'string'
> > > 188  * based on 'template'.
> > > 189  * The current time is either localtime or UTC based on 'utc'. */
> > > 190 void
> > > 191 ds_put_strftime_msec(struct ds *ds, const char *template, long long
> > int when,
> > > 192                      bool utc)
> > > 193 {
> > >
> > > It would require fixing the comments as well.
> >
> > I guess that some C++ program is including the header file, but that the
> > .c file is still compiled as C.
> >



More information about the dev mailing list