How could my code compile correctly without necessary headers?

前端 未结 3 1059
情书的邮戳
情书的邮戳 2021-01-18 03:19

I use the functions fork(),exec()...

But how can this program be compiled without including some extra headers (like sys/types.h, sys/wait.h).

I use ubuntu 1

3条回答
  •  离开以前
    2021-01-18 03:52

    exec and fork are declared in unistd.h, which is most likely included in one if stdio.h or stdlib.h which you explicitly specified in your code. "wait" is from sys/wait.h though... Try invoking gcc with -c -E to generate a preprocessed output and see where the functions' declarations come from.

提交回复
热议问题