Page 1 of 1

XBoard: C11 and more warnings

Posted: Sat Feb 29, 2020 2:31 pm
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.

Re: XBoard: C11 and more warnings

Posted: Sat Feb 29, 2020 2:51 pm
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.

Re: XBoard: C11 and more warnings

Posted: Sun Mar 01, 2020 2:22 pm
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__ */
[...]