Incompatible implicit declaration of built-in function ‘malloc’

前端 未结 5 834
走了就别回头了
走了就别回头了 2020-11-27 03:30

I\'m getting this error:

warning: incompatible implicit declaration of built-in function ‘malloc’

I am trying to do this:

<
相关标签:
5条回答
  • 2020-11-27 03:43

    You need to #include <stdlib.h>. Otherwise it's defined as int malloc() which is incompatible with the built-in type void *malloc(size_t).

    0 讨论(0)
  • 2020-11-27 03:45

    The stdlib.h file contains the header information or prototype of the malloc, calloc, realloc and free functions.

    So to avoid this warning in ANSI C, you should include the stdlib header file.

    0 讨论(0)
  • 2020-11-27 03:47

    You're missing #include <stdlib.h>.

    0 讨论(0)
  • 2020-11-27 03:51

    You likely forgot to include <stdlib.h>.

    0 讨论(0)
  • 2020-11-27 04:05

    The only solution for such warnings is to include stdlib.h in the program.

    0 讨论(0)
提交回复
热议问题