A
arnuld
I have checked the FAQ: http://c-faq.com/malloc/mallocnocast.html
FAQ discusses a special case when programmer has forgotten to do
#include <stdlib.h>. I am including this header and I am not doing any
explicit cast:
#include <stdlib.h>
enum ARRSIZE { MAXSIZE = 100 };
struct dummy
{
int i;
};
int main( void )
{
char *pc;
struct dummy *ptrDummy;
pc = malloc( MAXSIZE );
ptrDummy=malloc(sizeof(struct dummy));
return 0;
}
============ OUTPUT ============
/home/arnuld/programs/C $ gcc -ansi -pedantic -Wall -Wextra test.c
/home/arnuld/programs/C $ ./a.out
/home/arnuld/programs/C $
malloc(size_t n) returns a void pointer and here in my program, I am
assigning malloc returned pointers to 2 different types and I am not
getting any warnings about <implicit cast>.
It has something to do with C90 ?
FAQ discusses a special case when programmer has forgotten to do
#include <stdlib.h>. I am including this header and I am not doing any
explicit cast:
#include <stdlib.h>
enum ARRSIZE { MAXSIZE = 100 };
struct dummy
{
int i;
};
int main( void )
{
char *pc;
struct dummy *ptrDummy;
pc = malloc( MAXSIZE );
ptrDummy=malloc(sizeof(struct dummy));
return 0;
}
============ OUTPUT ============
/home/arnuld/programs/C $ gcc -ansi -pedantic -Wall -Wextra test.c
/home/arnuld/programs/C $ ./a.out
/home/arnuld/programs/C $
malloc(size_t n) returns a void pointer and here in my program, I am
assigning malloc returned pointers to 2 different types and I am not
getting any warnings about <implicit cast>.
It has something to do with C90 ?