warning: implicit declaration of function

前端 未结 7 810
旧时难觅i
旧时难觅i 2020-11-22 02:19

My compiler (GCC) is giving me the warning:

warning: implicit declaration of function

Please help me understand why is it coming

7条回答
  •  囚心锁ツ
    2020-11-22 02:59

    If you have the correct headers defined & are using a non GlibC library (such as Musl C) gcc will also throw error: implicit declaration of function when GNU extensions such as malloc_trim are encountered.

    The solution is to wrap the extension & the header:

    #if defined (__GLIBC__)
      malloc_trim(0);
    #endif
    

提交回复
热议问题