Strange XBoard function definitions

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Look
Posts: 366
Joined: Thu Jun 05, 2014 2:14 pm
Location: Iran
Full name: Mehdi Amini

Strange XBoard function definitions

Post by Look »

Hi,

Why so many such declarations/definitions exist in XBoard-4.9.1 ?

For instance from backend.h :

Code: Select all

void SetWhiteToPlayEvent P((void));
I did not see such a style even in K&R 2.
Farewell.
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: Strange XBoard function definitions

Post by xr_a_y »

User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Strange XBoard function definitions

Post by hgm »

P() is a macro #defined in common.h, as

Code: Select all

#if defined(__STDC__) || defined(WIN32) || defined(_amigados)
#define P(args) args
typedef void *VOIDSTAR;
#else
#define P(args)         ()
typedef char *VOIDSTAR;
#endif
It seems to be there or compatibility purposes with compilers that do not allow the function prototypes to have formal parameters.
User avatar
Look
Posts: 366
Joined: Thu Jun 05, 2014 2:14 pm
Location: Iran
Full name: Mehdi Amini

Re: Strange XBoard function definitions

Post by Look »

hgm wrote: Fri Oct 25, 2019 8:00 pm P() is a macro #defined in common.h, as

Code: Select all

#if defined(__STDC__) || defined(WIN32) || defined(_amigados)
#define P(args) args
typedef void *VOIDSTAR;
#else
#define P(args)         ()
typedef char *VOIDSTAR;
#endif
It seems to be there or compatibility purposes with compilers that do not allow the function prototypes to have formal parameters.
Are not these #else some ancient compilers whom have no practical use at such a date ?
Farewell.
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Strange XBoard function definitions

Post by hgm »

Probably. But old habits die hard.