On Mon, Dec 31, 2018 at 12:07:23AM +0100, Branko Čibej wrote: > Summary: I propose to create one or possibly several new public header > files that will be used by both the C and C++ public APIs. > > > I would like to completely hide the dependency on APR from the public > parts of the C++ API. In order to do that, public C++ headers must not > include the C headers directly, because most if not all of them do > expose APR. > > Up to now I've been "solving" this in an unsatisfactory and error-prone > way, redefining enumeration values in C++ to be the same as in C, > forward-declaring C structures in C++ headers, and so on. Instead, I'd > like to extract certain parts of the C public API into a new header that > is independent of APR, and use that in both APIs. This way I won't avoid > redefining enumerations, for example, but I can ensure that both the C > and C++ APIs use the same enumeration constant values. > > I'm attaching a patch that shows an example of what I have in mind. > > Please raise your objections by next year. :) > > -- Brane
> Index: subversion/include/svn__impl__types.h > =================================================================== > --- subversion/include/svn__impl__types.h (nonexistent) > +++ subversion/include/svn__impl__types.h (working copy) > @@ -0,0 +1,95 @@ > +/** > + * @copyright > + * ==================================================================== > + * Licensed to the Apache Software Foundation (ASF) under one > + * or more contributor license agreements. See the NOTICE file > + * distributed with this work for additional information > + * regarding copyright ownership. The ASF licenses this file > + * to you under the Apache License, Version 2.0 (the > + * "License"); you may not use this file except in compliance > + * with the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, > + * software distributed under the License is distributed on an > + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > + * KIND, either express or implied. See the License for the > + * specific language governing permissions and limitations > + * under the License. > + * ==================================================================== > + * @endcopyright > + * > + * @file svn_types.h > + * @brief Types implementation. > + * This is a @b private implementation-specific header file. > + * User code should not include it directly. > + */ > + > +#ifndef SVN_X_IMPL_X_TYPES_H > +#define SVN_X_IMPL_X_TYPES_H > + > +/* > + * Define Subversion types that do not depend on APR or other > + * external libraries (except for the C standard libvrary) and are > + * shared betwen the C and C++ APIs. Do not include any headers > + * except for the C standard library headers here. > + */ > + > +#ifdef __cplusplus > +extern "C" { > +#endif /* __cplusplus */ > + > +/* Tristate values > + * See: svn_tristate_t in svn_types.h > + * tristate in svnxx/tristate.hpp > + */ > +enum svn__impl__tristate_t In C++, identifiers with a double underscore _anywhere_ are reserved. Although it's unlikely that these names will end up being used by a compiler implementation somewhere, we probably shouldn't be using them. Cheers, -- James GPG Key: 4096R/91BF BF4D 6956 BD5D F7B7 2D23 DFE6 91AE 331B A3DB