XBoard: C11 and more warnings

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
Look
Posts: 254
Joined: Thu Jun 05, 2014 12:14 pm
Location: Iran
Full name: Mehdi Amini
Contact:

XBoard: C11 and more warnings

Post by Look » Sat Feb 29, 2020 1:31 pm

Hi,

I changed CFLAGS to following in XBoard Makefile (any better way?). Now there seems to be some problems with timeZone.

Code: Select all

CFLAGS = -std=c11 -Wall -Wextra -pedantic 
Note that I used -Weverything but I removed this since it produced massive number of warnings.

Now:

Code: Select all

#if HAVE_GETTIMEOFDAY
#include <sys/time.h>
//#include <sys/timeb.h>

    struct timeval timeVal;
    struct timezone timeZone;

    gettimeofday(&timeVal, &timeZone);
    tm->sec = (long) timeVal.tv_sec;
    tm->ms = (int) (timeVal.tv_usec / 1000L);

#else /*!HAVE_GETTIMEOFDAY*/
I get:

Code: Select all

backend.c: In function ‘GetTimeMark’:
backend.c:17839:21: error: storage size of ‘timeZone’ isn’t known
     struct timezone timeZone;
                     ^~~~~~~~
What can I do ?

Edit: Corrected title.

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

Re: XBoard: C11 and more warnings

Post by hgm » Sat Feb 29, 2020 1:51 pm

Says here the timezone argument of gettimeofday is obsolete. Apparently it is no longer defined in the system headers used with the C11 standard. Just set the second argument of gettimeofday to NULL, and delete the declaration. It was just passed as a dummy anyway, and not used for anything.

Look
Posts: 254
Joined: Thu Jun 05, 2014 12:14 pm
Location: Iran
Full name: Mehdi Amini
Contact:

Re: XBoard: C11 and more warnings

Post by Look » Sun Mar 01, 2020 1:22 pm

I added code like this , is it OK ?

Code: Select all

[...]
#if defined __STDC__

struct timezone {
    int tz_minuteswest;
    int tz_dsttime;
};
#endif /* __STDC__ */
[...]

Post Reply