malloc error on pointer

J

jt

Looks good to me, I don't understand whey the error below. Any reasons why
this would fail to compile.

Running on AIX using the CC compiler.

struct sockaddr *cliaddr;

"tcpserver.c", line 88.10: 1506-068 (W) Operation between types "struct
sockaddr *" and "int" is not allowed.
cliaddr=malloc(addrlen); //<---------this is the error
 
A

Andrey Tarasevich

jt said:
Looks good to me, I don't understand whey the error below. Any reasons why
this would fail to compile.

Running on AIX using the CC compiler.

struct sockaddr *cliaddr;

"tcpserver.c", line 88.10: 1506-068 (W) Operation between types "struct
sockaddr *" and "int" is not allowed.
cliaddr=malloc(addrlen); //<---------this is the error

Most likely compiler sees no declaration for 'malloc' function. Don't
forget to include 'stdlib.h' header file before using 'malloc' or any
other standard library functions declared in that file.
 
B

Ben Pfaff

jt said:
"tcpserver.c", line 88.10: 1506-068 (W) Operation between types "struct
sockaddr *" and "int" is not allowed.
cliaddr=malloc(addrlen); //<---------this is the error

You forgot to #include <stdlib.h>.
 
M

Martin Ambuhl

jt said:
Looks good to me, I don't understand whey the error below. Any reasons why
this would fail to compile.

Running on AIX using the CC compiler.

struct sockaddr *cliaddr;

"tcpserver.c", line 88.10: 1506-068 (W) Operation between types "struct
sockaddr *" and "int" is not allowed.
cliaddr=malloc(addrlen); //<---------this is the error

You forgot to
#include <stdlib.h>
so the (pre-C99) assumption that undeclared functions return ints.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,961
Messages
2,570,130
Members
46,689
Latest member
liammiller

Latest Threads

Top