Hi Stewart, all,
Stewart Smith wrote:
> Hi Monty,
> thanks for being able to have a look -
> On Thu, 2008-03-27 at 11:21 +0200, Michael Widenius wrote:
>>>>>>> "Stewart" == Stewart Smith <stewart@stripped> writes:
>> The only suggestions I have are the following:
>> - Instead of having 3 include files for sockets, do it with one.
>> ie, let my_socket.h handle all cases with ifdefs.
>> (Makes it easier to understand the socket interface with one glance)
> I prefer the style without #ifdefs everywhere, to me it makes it harder
> to read. You can currently read the whole implementation, in your native
> platform API (posix-y or win32) in about 3 screens of code. For seeing
> the differences between platforms, xxdiff actually works really well..
> although should only be needed when bugs are found in the abstraction.
> So I'd prefer to keep it how it is... but feel free to convince me
> otherwise or just say "thou shalt change it" :)
I strongly share Monty's preference for just a single file, with #ifdef
inside it to differentiate (where necessary):
1) It makes handling much easier, you cannot forget to transfer a file
just because you don't need it on your current platform.
2) When modifying the file, the risk of missing a branch is much reduced
if all branches are in the same file.
3) In case several branches share code, you avoid duplicating it.
4) If you have the #ifdef within definitions (say, within a typedef, or
a function), you are absolutely certain that all branches share the
same interface, and an "#else ; #error" branch will protect you
against forgetting any implementation for any branch
(immediately at definition point, not later at use point).
> Index: mysql-5.0-ndbwin32/include/my_socket.h
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ mysql-5.0-ndbwin32/include/my_socket.h 2008-03-26 15:09:07.246637043 +1100
> @@ -0,0 +1,12 @@
> +#ifndef MY_SOCKET_H
> +#define MY_SOCKET_H
> +#ifdef __WIN__
> +#include <my_socket_win32.h>
> +#include <my_socket_posix.h>
Please imagine adding a non-WIN non-Posix platform to this ...
Joerg Bruehe, Senior Production Engineer
MySQL AB, www.mysql.com
Office: (+49 30) 417 01 487 VoIP: 4464@stripped