Hi!
>>>>> "Tor" == Tor Didriksen <Tor.Didriksen@stripped> writes:
<cut>
Mats> In the event that the header file is included by some other file
>> that does a
Mats> similar forward declaration, the compiler will throw an error.
>>
>> We have already solved this in many places of MySQL / mysys by using
>> struct
>> foo for cases where the typedef is not yet done so I wouldn't call
>> this a notable problem.
>>
>> I also tested this with gcc and didn't get any error for the
>> following file:
>>
>> typedef struct foo FOO;
>> struct foo {int a;};
>> typedef struct foo FOO;
>>
>> struct foo a;
>> FOO b;
>>
>> What is it that would give an error?
Tor> You cannot use FOO in a forward declaration.
Example please.
<cut>
>> MySQL was coded in part so that it would be able to easily mix C++ and
>> C code and allow you to move things from C++ and C with little work.
>>
>> As MySQL is using C libraries with typedefs, you can't easily get rid
>> of all the typedefs.
Tor> I was asking for a deprecation of the rule, not a removal of *all*
Tor> typedefs.
Tor> Having typedefs in C-land makes sense (you save a few characters by typing
Tor> 'FOO' rather than 'struct foo'),
Tor> but not in C++ where 'foo' is handled as a type by the compiler.
Tor> Why do we want two different names for a thing, when one will do?
We don't need one, except in code with 'struct's that we may want to
make possible for someone to move to C.
A major issue with removing the typedefs is that it will cause a lot
of problems merging things between older releases.
Tor> The typedef rule is also used very inconsistently in the codebase
Tor> (see Roy's earlier example)
Yes, there is a couple of things that have become inconsistent over
time and should be fixed to have one coding standard.
Regards,
Monty