Invalid Operator to binary *
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Invalid Operator to binary *




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Invalid Operator to binary *  
Mihir


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-27-06 06:27 PM

I am getting this error for both "*" and "/"..

Here is the code from where it is coming...
----------------
#ifdef LINUX_OS
if (_TICKSPERSEC < 1000)
time_elapsed = (time_elapsed * (1000 / _TICKSPERSEC));
else
time_elapsed = (time_elapsed /(_TICKSPERSEC / 1000));
#else
#if (_TICKSPERSEC < 1000)
time_elapsed = (time_elapsed * (1000 / _TICKSPERSEC));
#else
time_elapsed = (time_elapsed /(_TICKSPERSEC / 1000));
#endif
#endif
----------------
_TICKSPERSEC is defined as "sysconf(_SC_CLK_TCK)" and time_elapsed is
defined as "unsigned long"

I also try modefying it to "*= " and "/="... but it still is giving me
same error.....






[ Post a follow-up to this message ]



    Re: Invalid Operator to binary *  
Paul D. Smith


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-27-06 06:27 PM

%% "Mihir" <patel.ma@gmail.com> writes:

m> I am getting this error for both "*" and "/"..

m> #if (_TICKSPERSEC < 1000)

m> _TICKSPERSEC is defined as "sysconf(_SC_CLK_TCK)"

The preprocessor needs to evaluate its arguments at compile time, so
all parts of an expression must be constant.  sysconf() is a runtime
function call, so you can't use it in a preprocessor statement.

--
----------------------------------------------------------------------------
---
Paul D. Smith <psmith@nortel.com>           HASMAT--HA Software Mthds & Tool
s
"Please remain calm...I may be mad, but I am a professional." --Mad Scientis
t
----------------------------------------------------------------------------
---
These are my opinions--Nortel takes no responsibility for them.





[ Post a follow-up to this message ]



    Re: Invalid Operator to binary *  
Mihir


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-27-06 06:27 PM

1 >> #ifdef LINUX_OS
2 >> if (_TICKSPERSEC < 1000)
3 >> time_elapsed = (time_elapsed * (1000 / _TICKSPERSEC));
4 >> else
5 >> time_elapsed = (time_elapsed /(_TICKSPERSEC / 1000));[vbcol=seagreen] 

On this block i am getting error on 3rd line and 5th line.

The exact error massege is "error: invalid operation to binary *" and
also for the 5th line
"error: invalid operation to binary /"

I have unistd.h included here. And I defined _TICKSPERSEC as
#define  _TICKSPERSEC  sysconf(_SC_CLK_TCK)






[ Post a follow-up to this message ]



    Re: Invalid Operator to binary *  
Eric Sosman


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-28-06 12:24 AM



Mihir wrote On 07/27/06 14:23,:
> 1 >> #ifdef LINUX_OS
>  2 >> if (_TICKSPERSEC < 1000)
>  3 >> time_elapsed = (time_elapsed * (1000 / _TICKSPERSEC));
>  4 >> else
>  5 >> time_elapsed = (time_elapsed /(_TICKSPERSEC / 1000)); 
>
> On this block i am getting error on 3rd line and 5th line.

This isn't the same code you posted in the first message.
Let me make a suggestion: Instead of posting approximations
plus explanations, try to construct a short, complete program
that demonstrates the problem -- fifteen or twenty lines ought
to do it, I'd think.  The post that entire chunk of code EXACTLY
as it stands: cut and paste, don't re-type.  That way, we'll
be debugging the actual code and not a series of approximations.

> The exact error massege is "error: invalid operation to binary *" and
> also for the 5th line
> "error: invalid operation to binary /"

Are these the EXACT error messages?  I doubt it ...  Again,
learn to cut and paste so as to avoid introducing inaccuracies.

--
Eric.Sosman@sun.com






[ Post a follow-up to this message ]



    Re: Invalid Operator to binary *  
Bjorn Reese


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-28-06 12:27 PM

Mihir wrote:
> 1 >> #ifdef LINUX_OS
>  2 >> if (_TICKSPERSEC < 1000)
>  3 >> time_elapsed = (time_elapsed * (1000 / _TICKSPERSEC));
>  4 >> else
>  5 >> time_elapsed = (time_elapsed /(_TICKSPERSEC / 1000)); 
>
> On this block i am getting error on 3rd line and 5th line.
>
> The exact error massege is "error: invalid operation to binary *" and
> also for the 5th line
> "error: invalid operation to binary /"
>
> I have unistd.h included here. And I defined _TICKSPERSEC as
> #define  _TICKSPERSEC  sysconf(_SC_CLK_TCK)

I cannot reproduce your problem:

[breese@stellifer:/home/breese/junk] cat ticspersec.c
#include <unistd.h>
#define  _TICKSPERSEC  sysconf(_SC_CLK_TCK)

int main(void)
{
unsigned long time_elapsed;
if (_TICKSPERSEC < 1000)
time_elapsed = (time_elapsed * (1000 / _TICKSPERSEC));
else
time_elapsed = (time_elapsed /(_TICKSPERSEC / 1000));
return 0;
}
[breese@stellifer:/home/breese/junk] gcc -Wall ticspersec.c
[breese@stellifer:/home/breese/junk]

As Eric said, please provide us with an exact example that fails.

--
mail1dotstofanetdotdk





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 03:45 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register