RE: [LIP] alloc functions and stdlib...
"Uday K Verma" <udayv-sA5OA4KG+12fsxuIvKNZIgC/[email protected]>
| Newsgroups | gmane.user-groups.linux.india.programmers |
|---|---|
| Message-ID | <[email protected]> |
Well, I'm not very sure about this, but at compilation time, when you don't include the stdlib.h, the function is assumed to be implicitly defined, so the compiler doesn't care (and know) what the function's signature is like (try passing more than one parameter to malloc and you would see it compile and link just fine), also it assumes that function returns an interger. The linker finds the malloc (or _malloc perhaps) symbol somewhere within the libraries and links to that. So, it sees the conversion from assumed interger return type of malloc to a char * or whatever, and reports a compile time warning. When you include stdlib.h, it knows what you malloc function looks like and reports no error (pointer to pointer conversion). It would also issue errors if singnatures don't match. Uday K Verma -----Original Message----- From: linux-india-programmers-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org [mailto:linux-india-programmers-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org] On Behalf Of Sameer Oak Sent: Wednesday, April 21, 2004 08:46 AM To: linux-india-programmers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Subject: [LIP] alloc functions and stdlib... alloc functions, malloc(), calloc(), realloc() need not type cast the return value if stdlib.h is included. what's the reason? - sameer oak. ********************************************************* Disclaimer: This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message and are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. ********************************************************* Visit us at http://www.mahindrabt.com ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ linux-india-programmers mailing list linux-india-programmers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/linux-india-programmers ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click