2

I keep receiving undefined identifier errors when invoking stdin and stdout despite having included stdio.h. I have looked for solutions to this but haven't found anything yet. Weirdly the program is still able to compile. I have already instructed the c_cpp_properties.json file to include the location of the header files in its path. If anybody would be able to help resolve this issue it would be greatly appreciated. Thank you.

VSCode version: Version 1.18.0 (1.18.0)

OS: macOS 10.13.1

Errors shown in the "Problems" section of VS Code

c_cpp_properties.json file

{
"configurations": [{
        "name": "Mac",
        "includePath": [
            "/usr/include",
            "/Library/Developer/CommandLineTools/usr/lib/clang/9.0.0/include/",
            "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1/tr1/",
            "/usr/include/c++/4.2.1",
            "/usr/local/include",
            "${workspaceRoot}"
        ],
        "defines": [],
        "intelliSenseMode": "clang-x64",
        "browse": {
            "path": [
                "/usr/include",
                "/usr/include/c++/4.2.1",
                "/Library/Developer/CommandLineTools/usr/lib/clang/9.0.0/include/",
                "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1/tr1/",
                "/usr/local/include",
                "${workspaceRoot}"
            ],
            "limitSymbolsToIncludedHeaders": true,
            "databaseFilename": ""
        },
        "macFrameworkPath": [
            "/System/Library/Frameworks",
            "/Library/Frameworks"
        ]
    },
    {
        "name": "Linux",
        "includePath": [
            "/usr/include",
            "/usr/local/include",
            "${workspaceRoot}"
        ],
        "defines": [],
        "intelliSenseMode": "clang-x64",
        "browse": {
            "path": [
                "/usr/include",
                "/usr/local/include",
                "${workspaceRoot}"
            ],
            "limitSymbolsToIncludedHeaders": true,
            "databaseFilename": ""
        }
    },
    {
        "name": "Win32",
        "includePath": [
            "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include",
            "${workspaceRoot}"
        ],
        "defines": [
            "_DEBUG",
            "UNICODE"
        ],
        "intelliSenseMode": "msvc-x64",
        "browse": {
            "path": [
                "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/*",
                "${workspaceRoot}"
            ],
            "limitSymbolsToIncludedHeaders": true,
            "databaseFilename": ""
        }
    }
],
"version": 3

}

Nightmayr
  • 21
  • 3
  • 4
    I can't see _anything_ on this screenshot. Please post the error messages as _formatted text_ instead of screenshots. Also, Visual Studio on a mac sounds just awful: why don't you use Xcode? It's free and designed specifically for macOS. – ForceBru Nov 14 '17 at 16:19
  • @ForceBru Apologies for that, the error is shown on the screenshot where I moused over the first `stdin`, however I should've shown the "problems" section. The error displayed is: `identifier "stdin" is undefined` as well as `identifier "stdout" is undefined`. I hope the issue is somewhat clearer now. I prefer VS Code to Xcode because it's much more lightweight compared to full fledged IDE like Xcode. – Nightmayr Nov 14 '17 at 17:00
  • @ForceBru: This is not Visual Studio but Visual Studio Code, which is actually a standalone editor made to be multi-platform. – Mikkel K. Nov 14 '17 at 17:01
  • Can you show your c_cpp_properties.json ? – Ahmed Masud Nov 14 '17 at 17:53
  • @AhmedMasud Yes certainly, a second screenshot containing the contents of the file has been edited into my original post. – Nightmayr Nov 14 '17 at 18:51
  • Add your include paths to your browse paths as well – Ahmed Masud Nov 14 '17 at 20:05
  • Also, for next time rather than putting in image URL please cut and paste the actual content in the question, so that it becomes searchable in the future. [ask] – Ahmed Masud Nov 14 '17 at 20:06
  • @AhmedMasud Ok thank you I'll make sure to do that in future. I've added the paths to my my browse paths however the error still seems to be present. I have added the c_cpp_properties.json into the question. – Nightmayr Nov 14 '17 at 20:33
  • Is this only an intellisense issue or your program fails to compile too? – Bob__ Nov 14 '17 at 20:57
  • 1
    Ah never mind I've managed to fix the issue. It was due to the line: `"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1/tr1/"`. I trimmed it down to `"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/"` on both the include paths and the browse paths, which seemed to do the trick. Thank you for the help @AhmedMasud – Nightmayr Nov 14 '17 at 20:58
  • 1
    @Bob__ It was just an intellisense issue I believe as the program was able to compile without a problem, however I have now managed to resolve the issue. – Nightmayr Nov 14 '17 at 21:01

0 Answers0