XBoard: C11 and more warnings

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

XBoard: C11 and more warnings

Post by Look »

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.
Farewell.
User avatar
hgm
Posts: 27787
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: XBoard: C11 and more warnings

Post by hgm »

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.
User avatar
Look
Posts: 364
Joined: Thu Jun 05, 2014 2:14 pm
Location: Iran
Full name: Mehdi Amini

Re: XBoard: C11 and more warnings

Post by Look »

I added code like this , is it OK ?

Code: Select all

[...]
#if defined __STDC__

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