473,324 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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 2514
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jagdeesh | last post by:
Hai Colleagues, I am using Tomcat 4.1.24 and JDK 1.4.0_03 in my winXP machine. I've transferred a set of folders(containing jsp files) into tomcat's webapps directory(to /webapps/bob ,...
6
by: paul calvert | last post by:
I hope somewhere here has encountered and solved a similar problem in the past. 1) on a new Win2000 PC: installed Visual C++ 6.0 download & install single file Service Pack 5.0 2) try to...
2
by: Mike Fisher | last post by:
I'm seeing an error when I try to run/debug a web service. Although it doesn't happen every time, it does occur more than half of the times I hit F5. It appears to be returned by the the JIT...
2
by: Mary | last post by:
Hello, I am having a problem with the cl compiler. I have written a C class (RegConnect.c) which uses Win32 API functions such as RegOpenKey, RegCloseKey etc. Initially when I was trying to...
0
by: rollasoc | last post by:
Hi, I seem to be getting a compiler error Internal Compiler Error (0xc0000005 at address 535DB439): likely culprit is 'BIND'. An internal error has occurred in the compiler. To work around...
1
by: Ayende Rahien | last post by:
reparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error (0xc0000005 at address 53168B12): likely culprit is 'BIND'. An internal...
6
by: David Lack | last post by:
Hi, I recently installed a 60-day trial of .NET 2003 on my development system. I made tests with previous personal projects (which compiled ok with VC6) and some open source files, and keep...
0
by: silviu | last post by:
Hello I'm trying to install Microsoft SQL 2005 Server Express Edition but I'm getting the following error: SQL Server Setup unexpectedly failed... Then it says something about a log file. Here's...
1
by: ganeshp | last post by:
Hi , When i try to build my appliation-1 and application-2 , I am experiencing below given errors OS: SUSE Linux Enterprise Server 10 (x86_64) VERSION = 10 PATCHLEVEL = 1 Compiler Version:
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.