3

The following code doesn't compile:

#include <stdio.h>
#include <malloc.h>

int
main(int argc, char *argv[])
{
   struct mallinfo mi;

   mi = mallinfo();

    return 0;
}
~/ssd/tmp$ gcc t.c
t.c: In function ‘main’:
t.c:8:20: error: storage size of ‘mi’ isn’t known
    struct mallinfo mi;
                    ^~
t.c:10:9: warning: implicit declaration of function ‘mallinfo’; did you mean ‘main’? [-Wimplicit-function-declaration]
    mi = mallinfo();
         ^~~~~~~~
         main
3
  • 3
    I can't reproduce this - do you perhaps have a non-standard version of malloc.h somewhere ahead of /usr/include/malloc.h in the compiler's include path (such as /usr/local/include)? May 17, 2019 at 0:18
  • you are right! there is a malloc.h inside /usr/local/include from other package. I removed it and it is working now. Thanks!
    – user952790
    May 17, 2019 at 1:37
  • @user952790 You can add that as an answer and mark it as accepted after 48 hours of posting the question. Thanks :)
    – Kulfy
    May 17, 2019 at 16:41

0

You must log in to answer this question.

Browse other questions tagged .