c/c++语言开发共享即使添加了#include ,也会隐式声明popen

这是我的代码的一小部分。

#include  #include  #include  #include  #include  #include  #include  #include  #include  #include  #include  #include  ... FILE * pipe; ... pipe = popen ("ls /tmp -1", "r"); ... pclose(pipe); 

 blarg.c:106: warning: implicit declaration of function 'popen' blarg.c:106: warning: assignment makes pointer from integer without a cast blarg.c:112: warning: implicit declaration of function 'pclose' blarg.c:118: warning: assignment makes pointer from integer without a cast 

我真的不确定。 我查了一下popen,它需要的是stdio.h。 缺少什么,或者是我的其余代码中的问题(我真的不想显示更多代码,因为它是一个赋值)。

    正如手册页所说:

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

    因此,在#include stdio.h之前,你应该#define _BSD_SOURCE或其中一个。

    -std=gnu99-std=gnu11替换-std=c99-std=c11等。

    我把popen和pclose的原型放在我的代码顶部。 它似乎解决了这个问题。

    需要了解更多c/c++开发分享即使添加了#include ,也会隐式声明popen,也可以关注C/ C++技术分享栏目—计算机技术网(www.ctvol.com)!

      以上就是c/c++开发分享即使添加了#include ,也会隐式声明popen相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/c-cdevelopment/979681.html

      (0)
      上一篇 2021年12月13日
      下一篇 2021年12月13日

      精彩推荐