473,320 Members | 2,177 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,320 software developers and data experts.

malloc error on pointer

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
Nov 14 '05 #1
4 2021
jt wrote:
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.

--
Best regards,
Andrey Tarasevich
Nov 14 '05 #2
"jt" <jt****@hotmail.com> writes:
"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>.
--
"Some people *are* arrogant, and others read the FAQ."
--Chris Dollin
Nov 14 '05 #3
jt wrote:
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.
Nov 14 '05 #4
jt
Thank you! I missed putting in the stdlib.h file.
JT
"Andrey Tarasevich" <an**************@hotmail.com> wrote in message
news:11*************@news.supernews.com...
jt wrote:
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.

--
Best regards,
Andrey Tarasevich

Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: mike79 | last post by:
hi all.. if I wanted to malloc a struct, say the following: struct myStruct1 { int number; char *string; }
34
by: Richard Hunt | last post by:
I'm sorry for asking such a silly question, but I can't quite get my head around malloc. Using gcc I have always programmed in a lax C/C++ hybrid (which I suppose is actually c++). But I have...
231
by: Brian Blais | last post by:
Hello, I saw on a couple of recent posts people saying that casting the return value of malloc is bad, like: d=(double *) malloc(50*sizeof(double)); why is this bad? I had always thought...
11
by: Mannequin* | last post by:
Hi all, I'm working on a quick program to bring the Bible into memory from a text file. Anyway, I have three questions to ask. First, is my implementation of malloc () correct in the program to...
58
by: lasek | last post by:
Hi all..i'm here another time..for a simple question: #include <stdlib.h> #include <stdio.h> int main(void) { /* ** I know that someone else use different malloc ** instruction
54
by: Neo | last post by:
Hi Folks, I've a simple qestion related to dynamic memory allocation in C here is the code: #include <stdio.h> int main() {
68
by: James Dow Allen | last post by:
The gcc compiler treats malloc() specially! I have no particular question, but it might be fun to hear from anyone who knows about gcc's special behavior. Some may find this post interesting;...
25
by: Why Tea | last post by:
Thanks to those who have answered my original question. I thought I understood the answer and set out to write some code to prove my understanding. The code was written without any error checking....
10
by: somenath | last post by:
Hi All, I have one question regarding return value cast of malloc. I learned that we should not cast the return value of malloc because it is bug hider. But my question is as mentioned...
25
by: jbholman | last post by:
I am pretty new to C and doing my first project in C. I actually read almost the entire FAQ, but can't seem to figure out this problem. I have a structure. I have a list of these structures. ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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: 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: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.