VSCodeでaddrinfo がエラーになる
上の画像のようにaddrinfo
の変数にエラーが出る。
実際にはコンパイルできるが、エラーが邪魔である。
解決方法は、上記issueの通り、
- ctrl + shift + P で
C/C++ : Edit Configuretions
を開く(UI/JSONどちらでもよい) Defines
の項目を見る- 以下のように書き換え
- "defines": [ - ], + "defines": [ + "__linux__", + "__x86_64__", + "_GNU_SOURCE" + ],
{ "configurations": [ { "name": "Linux", "includePath": [ "${workspaceFolder}/**" ], "defines": [ "__linux__", "__x86_64__", "_GNU_SOURCE" ], "compilerPath": "/usr/bin/gcc", "intelliSenseMode": "linux-gcc-x64", "cStandard": "c11", "cppStandard": "c++17" } ], "version": 4 }
UIの場合はこう