0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C/C++ for Visual Studio Codeで標準ヘッダにあるはずの型が見つからない

Last updated at Posted at 2020-01-23

問題

C/C++ for Visual Studio Code で標準ヘッダー(unistd.h)にあるはずの pid_t について画像のようにidentifier "pid_t" is undefined が表示される.
Screenshot from 2020-01-23 00-13-10.png

だが gcc では問題なくコンパイルされる.

原因

unistd.h 内の pid_t の定義は _GNU_SOURCE が定義されていることに依存する.

解決方法

VSCode のコマンドパレット > C/C++: Edit configurations (UI)
から Compiler arguments-D_GNU_SOURCE を追加する.

環境

  • Ubuntu 18.04
  • gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
  • C/C++ for Visual Studio Code Version 0.26.3-insiders4: January 16, 2020

参考

0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?