Solved

I am lost with the C time tm struct

Posted on 2014-09-30
3
206 Views
Last Modified: 2014-09-30
I am transfering old libs from bcc32 to tcc. I am blocked by this one in the marked line. Tcc says "structure or union expected".

Question: what is wrong with tcc.

The rest of the function is not debugged yet, tcc seems to proceed one problem at a time.
Thank you for your help.

long m_time(long tim0)
{
long   tx;
int    k;
int    mod;
int    mois, an;
struct tm * t;
time_t timer;
char   fig[10];
int    i;

   time(&timer);
   t=localtime(&timer);
   sprintf(mc_eurodate,"%02d/%02d/%02d %02d:%02d:%02d",
           t.tm_mday,t.tm_mon,t.tm_year+1900,t.tm_hour,t.tm_min,t.tm_sec);    <=== error line.
   sprintf(mc_univdate,"%04d/%02d/%02d %02d:%02d:%02d",
           t.tm_year+1900,t.tm_mon,t.tm_mday,t.tm_hour,t.tm_min,t.tm_sec);
   sprintf(mc_gdh     ,"%04d%02d%02d%02d%02d%02d",
           t.tm_year+1900,t.tm_mon,t.tm_mday,t.tm_hour,t.tm_min,t.tm_sec);
   sprintf(mc_soa     ,"%04d%02d%02d%02d",
           t.tm_year+1900,t.tm_mon,t.tm_mday,t.tm_hour);
   sprintf(mc_hour    ,"%02d", t.tm_hour );
   sprintf(mc_zipdate ,"%02d%02d%04d", t.tm_mon,t.tm_mday,t.tm_year+1900);
   sprintf(curr_date,"%-8.8s",mc_gdh);
   sprintf(mc_collmois,"%04d%02d",t.tm_year+1900,t.tm_mon);
   mois=d.da_mon;
   an  =t.tm_year+1900&100;
   memmove(mc_collmois,&mc_collmois[2],5);
   sprintf(mc_collweek,"%04ld",(timer+86400L*(t.tm_day+2L)+
           3600L*t.tm_hour)/604800L-524L);
   sprintf(mc_collday,"%0ld",(timer/86400L)-3653L);
   if (strlen(mc_collday)==5) memmove(mc_collday,&mc_collday[1],5);
  
   for (i=0;i<6;i++)
   {
      sprintf(mc_mois[0],"%02d%02d",an, mois--);
      if (mois==0) {mois=12; an--;}
   }

   tx=timer-315360000L;
   memset(fig,0,10);
   memset(fig,' ',9);
   k=7;
   while(1)
   {
      mod=tx%34;
      if      (mod<8)   fig[k]=mod+'A';
      else if (mod<13)  fig[k]=mod+'A'+1;
      else if (mod<24)  fig[k]=mod+'A'+2;
      else              fig[k]=mod+'0'-24;
      k--;
      if ((tx=tx/34)==0L) break;
   }
   m_head(fig);
   m_short(fig);
   sprintf(mc_ref,"%s",fig);

   mois=t.tm_mon;
   an  =t.tm_year+1900;
   mois=mois-7;
   if (mois<1) {mois=12+mois; an--;}
   sprintf(mc_six,"%04d%02d",an,mois); 
   mois=t.tm_mon;
   an  =t.tm_year+1900;
   mois=mois-12;
   if (mois<1) {mois=12+mois;an--;}
   sprintf(mc_eleven,"%04d%02d",an,mois); 
   return(timer+tim0);
}

Open in new window

0
Comment
Question by:versailles
3 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 500 total points
ID: 40352200
Hi versailles,

the problem IMO is you use '.' instead of '->' to access members of 't' (which is a pointer).

So you should replace all statements like ' t.tm_mda' with ' t->tm_mda'.

Hope that helps,

ZOPPO
0
 

Author Closing Comment

by:versailles
ID: 40352307
This does help !
Silly of mine. I am somewhat rusty with my C. I change compiler because BCC32 is out of commission now.
Thank you!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question