Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I still can't figure my compiling error

Status
Not open for further replies.

RandallW

Programmer
Jun 24, 2000
18
0
0
US
I'm using the time function in a program; the compiler says
"the term does not evaluate to a function"

Here is the piece of code that causes the trouble ( along with some surrounding code )
Code:
for ( dummy = 1; dummy <= jobs; dummy++ )
{ // begin 'dummy' and 'jobs'
   if ( seed_defined )
      time;
   else
   {
      time ( &time_returned );
   }
   .
   .
   .
   .
}

The error occurs at
Code:
 time ( &time_returned );
time_returned is a long type; i've tried a different type; same error.
If I use the time function in a test program, where it's the only statement in
Code:
 main
, it compiles fine;
I've looked at all my brackets and 'if-else's....they look fine.

I wish this site allowed me to attach the program; it would
make things so much easier.

 
Just a shot in the dark; try changing the type of your variable time_returned. Instead of long, define it as time_t (which is a long) -- maybe that will &quot;unconfuse&quot; the compiler.

Hope that helps.

Pat Gleason
gleason@megsinet.net

 
I've used different types in the variable of
Code:
 time
....sometimes an int, sometimes a long, sometimes a
time_t.....same resulting error.....would anyone allow me to
e-mail the whole program so you could look at it? It's only 5k.
 
maybe the first call to time (1) confuses the compliler into thinking that time is a variable (because there are no brackets () ). But when it reaches the second call to time it is being called as a function but the compiler has already decided that it is a variable.

if ( seed_defined )
time; // (1)
else
{
time ( &time_returned );// (2)
}


mail me the code if you are still stuck and this does not work.

richardfrenchuk@yahoo.com





 
Hi,
Tried your code(with slight diff's) and it worked fine.

Here's mine

/*********START CODE*****/

#include <time.h>

main()
{
long time_returned;
int seed_defined;

if(seed_defined)
time;
else
{
time ( &time_returned );
}
}

/*********END CODE*******/

I did get errors when I did not include time.h.

Pappy
 
Hi again,

I turned up the warnimg level and it pointed out that the line

if(seed_defined)
time; // This line

has no effect.

What is this line supposed to do?

Pappy
 
I was using
Code:
 time
as testing of the function;
I was trying to pin down which specific ways of using it were causing my error.
 
looking at the whole code that you emailed me, i can see you have defined an array called time at the beginning of the main function :

int submit [ 50000 ], nio, length, dummy2, generated_burst, holder, time [ 50000 ], r0 [ 50000 ], r1 [ 50000 ];

This confuses the compiler into thinking that time is a variable and not a function.

If you change the Array &quot;time&quot; to a better name like timearray and it will compile ok.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top