469,081 Members | 1,789 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,081 developers. It's quick & easy.

Error with cc sunstudio compiler

I compiled that program under turbo C without any problems but with
sunstudi I found those errors:

"pnt02ma1.c", line 37: warning: implicit function declaration: system
"pnt02ma1.c", line 58: operands must have arithmetic type: op "*"
"pnt02ma1.c", line 58: assignment type mismatch:
pointer to float "=" double
"pnt02ma1.c", line 59: operands must have arithmetic type: op "/"
"pnt02ma1.c", line 60: operands have incompatible types:
pointer to float "-" double
"pnt02ma1.c", line 61: operands must have arithmetic type: op "/"
"pnt02ma1.c", line 62: operands have incompatible types:
pointer to float "-" double
"pnt02ma1.c", line 62: warning: improper pointer/integer combination:
op "="
cc: acomp failed for pnt02ma1.c
/*-----------------------pnt02ma1.c---------------------
Given those formulas
---inch = cm / 2.45
---inch =(meter * 100)/2.45
---feet = 12 inch
---yard = 3 feet
---yard = 36 inch
---inch = 1/12 feet
---inch = 1/36 yard

---yard feet inch

convert given meter value to (yards , feet , and inches)

1-convert meter to the smallest unit = (inches).
2-obtain yards (biggest required value).
3-obtain the remainder inches after getting yards. m=m%36
4-obtain feet (second biggest required value).
5-obtain the remainder inches after getting feets.i=m%12
---------------------------------------*/
#include "stdio.h"

void input(float *);
void conversion(float *,int *,int *,int *);
void print_reults(float *,int *,int *,int *);
char another(void);

int main ()
{
float meter;
int yards,feet,inches;
do {
system("cls");
input(&meter);
conversion(&meter,&yards,&feet,&inches);
} while (another()=='y');
return 0;
}
void input(float *m)
{
printf("\nEnter size in meter :");
scanf("%f",m);
printf("\nYou have entered size in meter %.4f\n",*m);

}
void conversion(m,y,f,i)
float *m;
int *y,*f,*i;
{
m=m*100.0/2.54;
*y=m/36.0;
m=m-(*y)*36.0;
*f=m/12.0;
*i=m-(*f)*12.0;
printf("\n %.2f meter is = %4d yards %4d feet %4d inches
",*m,*y,*f,*i);
}
char another()
{
char a;
printf("\n\n Do ou want to another procees (y/n)");
scanf("\n%c",&a);
return (a);
}
Jun 27 '08 #1
5 2281
happytoday wrote:
I compiled that program under turbo C without any problems but with
sunstudi I found those errors:

"pnt02ma1.c", line 37: warning: implicit function declaration: system
"pnt02ma1.c", line 58: operands must have arithmetic type: op "*"
"pnt02ma1.c", line 58: assignment type mismatch:
pointer to float "=" double
"pnt02ma1.c", line 59: operands must have arithmetic type: op "/"
"pnt02ma1.c", line 60: operands have incompatible types:
pointer to float "-" double
"pnt02ma1.c", line 61: operands must have arithmetic type: op "/"
"pnt02ma1.c", line 62: operands have incompatible types:
pointer to float "-" double
"pnt02ma1.c", line 62: warning: improper pointer/integer combination:
op "="
cc: acomp failed for pnt02ma1.c
So? These are all valid diagnostics, study them and fix the code.
>
void conversion(m,y,f,i)
float *m;
int *y,*f,*i;
{
Why are you using obsolete K&R functions?

--
Ian Collins.
Jun 27 '08 #2
happytoday wrote:
I compiled that program under turbo C without any problems but with
sunstudi I found those errors:

"pnt02ma1.c", line 58: operands must have arithmetic type: op "*"
This is the offending line

m=m*100.0/2.54;

where 'm' is declared as 'float*'. Not surprisingly, the compiler
complains. I don't know how you managed to compile it in turbo C and,
frankly, I don't believe it is possible.

--
Best regards,
Andrey Tarasevich
Jun 27 '08 #3
happytoday wrote:
I compiled that program under turbo C without any problems
Then Turbo C must be even crapier than I thought.
but with sunstudi I found those errors:

"pnt02ma1.c", line 37: warning: implicit function declaration: system
You should include <stdlib.hto get the prototype for system(), even
if the implicit one (under C90) happens to be okay.
"pnt02ma1.c", line 58: operands must have arithmetic type: op "*"
"pnt02ma1.c", line 58: assignment type mismatch:
pointer to float "=" double
"pnt02ma1.c", line 59: operands must have arithmetic type: op "/"
"pnt02ma1.c", line 60: operands have incompatible types:
pointer to float "-" double
"pnt02ma1.c", line 61: operands must have arithmetic type: op "/"
"pnt02ma1.c", line 62: operands have incompatible types:
pointer to float "-" double
"pnt02ma1.c", line 62: warning: improper pointer/integer combination:
op "="
cc: acomp failed for pnt02ma1.c

<snip>
#include "stdio.h"
#include <stdio.h>
>
void input(float *);
void conversion(float *,int *,int *,int *);
void print_reults(float *,int *,int *,int *);
char another(void);

int main ()
{
float meter;
int yards,feet,inches;
do {
system("cls");
This is unlikely to work under *nix.

<snip>
void conversion(m,y,f,i)
float *m;
int *y,*f,*i;
Don't use old K&R style function declarations.

void conversion(float *m, int *y, int *f, int *i)
{
m=m*100.0/2.54;
What is the type of m? What does it mean to multiply a
pointer by a double?

<snip>

--
Peter
Jun 27 '08 #4
In comp.unix.programmer happytoday <eh**********@gmail.comwrote:
I compiled that program under turbo C without any problems but with
sunstudi I found those errors:
"pnt02ma1.c", line 37: warning: implicit function declaration: system
"pnt02ma1.c", line 58: operands must have arithmetic type: op "*"
"pnt02ma1.c", line 58: assignment type mismatch:
pointer to float "=" double
"pnt02ma1.c", line 59: operands must have arithmetic type: op "/"
"pnt02ma1.c", line 60: operands have incompatible types:
pointer to float "-" double
"pnt02ma1.c", line 61: operands must have arithmetic type: op "/"
"pnt02ma1.c", line 62: operands have incompatible types:
pointer to float "-" double
"pnt02ma1.c", line 62: warning: improper pointer/integer combination:
op "="
cc: acomp failed for pnt02ma1.c
I somehow doubt that the program when compiled with Turbo C
did anything reasonable. Most compilers are a bit more picky,
which has the advantage that you get some idea what you did
wrong instead of ending up with a program that does something
strange.
#include "stdio.h"
void input(float *);
void conversion(float *,int *,int *,int *);
void print_reults(float *,int *,int *,int *);
char another(void);
int main ()
Better make that

int main( void )
{
float meter;
int yards,feet,inches;
do {
system("cls");
system(3) is declared in <stdlib.hwhich you didn't include.
You may also find that 'cls' isn't a command that the shell
knows about, SunOS (or whatever your machine is running) is
not DOS...
input(&meter);
conversion(&meter,&yards,&feet,&inches);
} while (another()=='y');
return 0;
}
void input(float *m)
{
printf("\nEnter size in meter :");
scanf("%f",m);
Using scanf() for getting input from a user is rather difficult
to get right. Just try what happens if you enter something else
than a number here...
printf("\nYou have entered size in meter %.4f\n",*m);
}
void conversion(m,y,f,i)
float *m;
int *y,*f,*i;
Why are you mixing the very-old style of specifying function para-
meters with the "new" (but already 18 years old) way? Better use

void conversion( float *m, int *y, int *f, int *i )
{
m=m*100.0/2.54;
I guess you meant

*m = *m * 100.0 / 2.54;
*y=m/36.0;
And here:

*y = *m / 36.0;

And the same in the next three lines. BTW, why do you pass pointers
to the function if you don't have to? It doesn't look as if you are
interested in changes to these values in the caller.
m=m-(*y)*36.0;
*f=m/12.0;
*i=m-(*f)*12.0;
printf("\n %.2f meter is = %4d yards %4d feet %4d inches",*m,*y,*f,*i);
}
char another()
Also here it's better use

char another( void )
{
char a;
printf("\n\n Do ou want to another procees (y/n)");
scanf("\n%c",&a);
return (a);
}
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
Jun 27 '08 #5
happytoday wrote:
I compiled that program under turbo C
Get rid of turbo C since it's outdated. The C language has changed
considerably since then. You will not learn correct C by reading turbo
C tutorials. That means programs you write are not valid C these days.
Jun 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Mike Fisher | last post: by
2 posts views Thread by Mary | last post: by
reply views Thread by rollasoc | last post: by
1 post views Thread by Ayende Rahien | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.