[Freeciv-Dev] Re: (PR#11213) Making client headers compatible with C++
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=11213 >
Frédéric Brière wrote:
>>ever came of it except broken code. Renaming elements to avoid keywords
>>is okay, but adding casts to void pointers is just ugly. Can't you use
>
>
> I did nothing of the sort. If you look at the patch, you'll see that I
> cast a void pointer *to* a SPECLIST_TYPE (or SPECVEC_TYPE) pointer,
> which is the return type of the function. There was already an implicit
> cast going on, and I merely made it explicit. (C++ doesn't allow
> implicit conversion from void pointers, to prevent bad surprises.)
You cast a void pointer as a SPECLIST_TYPE one. C allows implicit
conversion from void pointers, to...prevent bad surprises. Forcing a
cast is annoying but not fatal. But it's best to avoid where possible.
Having it only in the headers is okay since this should be a rare
situation (inline functions and a few macros).
>>C bindings for Qt? Or is it possible some of these errors are just
>>warnings, and can be ignored?
>
> Given how much time I spent Googling to make sure I knew which part of
> the standard was involved for each item, I'm pretty confident. (The
> story behind disallowing forward declaration of enums is quite
> interesting, BTW.) I didn't want to bother you with too many details,
> but if you'd like a more thorough explanation of some or all of the
> problems I raised, I'd be glad to oblige you.
The enum is a minor issue.
Before we start changing things I think we should agree on a standard.
The last time someone started writing a C++ client I believe all sorts
of code got changed for the worse. But from what you say it seems only
the headers need changing. Can we make only the headers (.h files) C++
compatible, and allow C++ clients to be compiled? If so that should be
the standard.
You should provide patches for each element one at a time so we can
discuss them. I believe there's already a patch for stdbool in RT
somewhere, which looks okay.
jason
|
|