Thread: error: storage size of ‘tz’ isn’t known

  1. #1
    programmer hacker DevZero's Avatar
    Join Date
    Jul 2017
    Posts
    42

    error: storage size of ‘tz’ isn’t known

    This function is not mine, I took it from the Internet. Here's the code:
    Code:
    #include <sys/time.h>
    #include <stdio.h>
    
    struct timeval tv1,tv2,dtv;
    struct timezone tz;
    void time_start() { gettimeofday(&tv1, &tz); }
    long time_stop()
    { gettimeofday(&tv2, &tz);
      dtv.tv_sec= tv2.tv_sec -tv1.tv_sec;
      dtv.tv_usec=tv2.tv_usec-tv1.tv_usec;
      if(dtv.tv_usec<0) { dtv.tv_sec--; dtv.tv_usec+=1000000; }
      return dtv.tv_sec*1000+dtv.tv_usec/1000;
    }
    
    int main()
    {
    	time_start();
    	for(int t=0; t<1000000; t++)
    	    printf("Test 1: %d\n", t);
    	printf("Result: %ld\n", time_stop());
    }
    I compile it and see this error:
    test.c:5:17: error: storage size of ‘tz’ isn’t known
    struct timezone tz;
    ^

  2. #2
    Registered User
    Join Date
    Sep 2014
    Posts
    364
    From man-page:

    Code:
    The use of the timezone structure is obsolete; the tz argument should
    normally be specified as NULL.  (See NOTES below.)
    …
    Of course it turned out that the period in which Daylight Saving Time
    is in force cannot be given by a simple algorithm, one per country;
    indeed, this period is determined by unpredictable political
    decisions.  So this method of representing timezones has been
    abandoned.
    This means, you should use:
    Code:
    gettimeofday(&tv1, NULL);
    Other have classes, we are class

  3. #3
    programmer hacker DevZero's Avatar
    Join Date
    Jul 2017
    Posts
    42
    Quote Originally Posted by WoodSTokk View Post
    From man-page:

    Code:
    The use of the timezone structure is obsolete; the tz argument should
    normally be specified as NULL.  (See NOTES below.)
    …
    Of course it turned out that the period in which Daylight Saving Time
    is in force cannot be given by a simple algorithm, one per country;
    indeed, this period is determined by unpredictable political
    decisions.  So this method of representing timezones has been
    abandoned.
    This means, you should use:
    Code:
    gettimeofday(&tv1, NULL);
    Thanks, all worked well

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. storage size i and o is unknown error
    By zolfaghar in forum C Programming
    Replies: 8
    Last Post: 06-05-2016, 12:41 PM
  2. storage size of 'sin' isn't known
    By mariab in forum Networking/Device Communication
    Replies: 3
    Last Post: 11-10-2008, 09:01 AM
  3. compile error: storage size of 'var' isn't known
    By George2 in forum C Programming
    Replies: 9
    Last Post: 04-03-2007, 05:45 AM
  4. storage size of regs is unkown
    By Vertex34 in forum C Programming
    Replies: 5
    Last Post: 11-04-2003, 10:17 AM
  5. Replies: 0
    Last Post: 04-29-2003, 09:23 PM

Tags for this Thread