popen implicitly declared even though #include is added

前端 未结 3 2031
借酒劲吻你
借酒劲吻你 2020-12-15 21:40

This is tiny snippet of my code.

   #include 
   #include 
   #include 
   #include 
   #include         


        
相关标签:
3条回答
  • 2020-12-15 22:09

    Replace -std=c99 or -std=c11 etc with -std=gnu99 or -std=gnu11.

    0 讨论(0)
  • 2020-12-15 22:27

    I put the prototypes of popen and pclose at the top of my code. It seemed to have settled the problem.

    0 讨论(0)
  • 2020-12-15 22:28

    As the man page says:

    Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
    
    popen(), pclose(): _POSIX_C_SOURCE >= 2 || _XOPEN_SOURCE || _BSD_SOURCE
    || _SVID_SOURCE
    

    So you should #define _BSD_SOURCE or one of the others before #includeing stdio.h.

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