nxdk icon indicating copy to clipboard operation
nxdk copied to clipboard

VSCode Intellisense fails when including NXDK PDCLib

Open GXTX opened this issue 5 years ago • 5 comments
trafficstars

I'm attempting to get VSCode's intellisense to handle NXDK but I seem to be running into an issue.

This is the error code when you do not set the correct location: cannot open source file "pdclib/_PDCLIB_config.h" (dependency of "stdint.h")

You can get it to work even with the error above (just missing hints for those parts) by setting "C_Cpp.intelliSenseEngineFallback": "Enabled". If you correctly set the include folder for that header intellisense will stop finding hints for everything however it will stop complaining about the error.

Here is my current config:

{
	"C_Cpp.intelliSenseEngineFallback": "Enabled",
	"C_Cpp.default.systemIncludePath": [
		"/home/wsl/Projects/nxdk/lib/", 
		"/home/wsl/Projects/nxdk/lib/winapi/",
		"/home/wsl/Projects/nxdk/lib/pdclib/include/",
		//"/home/wsl/Projects/nxdk/lib/pdclib/platform/xbox/include/" // <- this is the problem
	],
}

I know the big guys around these parts don't very much care for such features but I find it incredibly helpful and I'm sure new users would as well.

Any ideas or guidance?

GXTX avatar Jul 01 '20 21:07 GXTX

changed the title ~~"VSCode Intellisense fails with PDCLib VSCode"~~ "Intellisense fails when including NXDK PDCLib"

Did you try it with another pdclib platform (like the example platform)? Did you try stripping the xbox pdclib folder to find the error-source?

(Note: We use "nxdk" in lowercase for consistency. NXDK is only to be used in code / macros)

cannot open source file "pdclib/_PDCLIB_config.h" (dependency of "stdint.h")

I have trouble understanding this message, because stdint.h doesn't seem to include this file. Can you provide more information somehow? I'd expect a chain of dependencies.

Did you try re-ordering the list of include paths? Is this simply about multiple include paths having a "pdclib" subfolder?

Potentially report these issues to MS (poor error message + poor intellisense for the given project).

Also note that MS compilers have a very weird set of include path rules, which often breaks (it does weird stuff like looking in parent folders I believe). I'm not sure if it's possible to set a different (clang/gcc conformant) include order for intellisense. Again, this might be a potential issue that should be reported to MS.

I know the big guys around these parts don't very much care for such features

  1. There are no "big guys" here, only regular contributors, and maintainers (who have more of a moderating role and a rough direction).
  2. A couple of people (including different maintainers) have already expressed, on multiple occasions, that we should have better IDE support; however, we need people to work on it. And so far, nobody of the regular contributors uses Visual Studio, so this is a non-issue to them. If you want good intellisense support, work on it - if it's good then it will likely be included.

So tracking the issue here is fine, although I feel like it might be better suited for a separate repo which packages nxdk (as a submodule for example) in a Visual Studio extension / plugin. I personally feel like nxdk should provide the most critical libraries and potentially a build-system; but integeration with IDEs (including installer-packages for end-users) and other libraries should potentially happen elsewhere.

JayFoxRox avatar Jul 02 '20 14:07 JayFoxRox

Off platform we talked about include orders and properly setting system includes vs. normal includes. I went ahead based on information from make V=1 changed the include paths to include everything that the hello sample would normally include.

I've made sure to set the include order in the same as make V=1 shows, correctly set the mode to clang-x86, properly set the compiler path, made sure to set the c standard to. Intellisense no longer complains but still does not give type hints.

Full config as follows.

{
	"C_Cpp.default.intelliSenseMode": "clang-x86",
	"C_Cpp.default.compilerPath": "/usr/bin/clang",
	"C_Cpp.default.includePath": [
		"${workspaceFolder}/**",
		"/home/wsl/Projects/nxdk/lib/", 
		"/home/wsl/Projects/nxdk/lib/xboxrt/libc_extensions/",
		"/home/wsl/Projects/nxdk/lib/hal/",
		"/home/wsl/Projects/nxdk/lib/pdclib/include/",
		"/home/wsl/Projects/nxdk/lib/pdclib/platform/xbox/include/",
		"/home/wsl/Projects/nxdk/lib/winapi/",
		"/home/wsl/Projects/nxdk/lib/xboxrt/vcruntime/",
		"/home/wsl/Projects/nxdk/lib/winapi/winmm/",
		"/home/wsl/Projects/nxdk/lib/zlib/zlib/",
		"/home/wsl/Projects/nxdk/lib/libpng/",
		"/home/wsl/Projects/nxdk/lib/libjpeg/",
	],
	"C_Cpp.default.systemIncludePath": [
		"/home/wsl/Projects/nxdk/lib/pdclib/include/",
		"/home/wsl/Projects/nxdk/lib/libjpeg/libjpeg-turbo",
	],
	"C_Cpp.default.cStandard": "c11",
	"C_Cpp.default.cppStandard": "c++14",
}

GXTX avatar Jul 02 '20 15:07 GXTX

Can you go into detail as to where exactly you encounter the issue? I'm very much interested in having a better IDE compatibility as it is an area where we currently lack in providing a good out-of-the-box experience compared to the XDK. I'm currently using VSC for almost everything I do regarding nxdk, but I mostly just ignored the cases where highlighting etc. failed.

I'm currently experimenting with this:

{
    "C_Cpp.default.compilerPath": "/usr/bin/clang",
    "C_Cpp.default.cppStandard": "c++20",
    "C_Cpp.default.cStandard": "c18",
    "C_Cpp.default.intelliSenseMode": "msvc-x86",
    "C_Cpp.default.systemIncludePath": [
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/xboxrt/libc_extensions",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/hal",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/libjpeg/libjpeg-turbo",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/libpng",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/libpng/libpng",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/libjpeg/libjpeg-turbo",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/net/lwip/src/include",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/net/nforceif/include",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/pktdrv",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/zlib",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/winapi",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/sdl",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/sdl/SDL2/include",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/sdl/SDL2_image",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/sdl/SDL_ttf",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/nxdk",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/pbkit",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/pktdrv",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/pdclib/include",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/pdclib/platform/xbox/include",
    ],
    "C_Cpp.default.includePath": [
        "${workspaceFolder}/**",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/pdclib/include",
        "/home/venom/Sync/xbox_dev/nxdk-nvnetdrv/lib/pdclib/platform/xbox/include",
    ],
    "C_Cpp.default.defines": [
        "NXDK",
        "XBOX",
        "SDL_BYTEORDER=1234",
    ],
    "C_Cpp.default.compilerArgs": [
        "-target i386-pc-win32",
    ]
}

It's not ideal, either - the libcxx includes are missing, but they contain headers that are named the same as the PDCLib ones, so they should only be used for C++, not C. Also __linux__ seems to be defined, so I'm using the endianess define to fix an error about not having endian.h. There is some stuff out there on how to configure VSC for cross compilation, but I have no experience doing this so far and all the info seems to rely on having a "proper" gcc-based cross-compiler.

Is there a way to ship something like this with nxdk (obviously concerned by the absolute paths)? Could we maybe automatically retrieve some of this from a better build system, say, a CMake based one?

thrimbor avatar Jul 03 '20 17:07 thrimbor

Thanks for looking into it Thrimbor.

I encountered issues when creating a small script for writing eeproms to Xbox see my gist here. The specific issue is that when I properly include lib/pdclib/platform/xbox/include this breaks type hints for everything and even says main has a problem see attached image. image

For the sake of it I attempted to steal your entire config and I have the same issue.

We also all talked off platform about using "C_Cpp.intelliSenseEngine": "Tag Parser", however JFR suggests this is dirty and should be avoided, but when I use tag parsing I have no issues (so long as I include the bare minimum excluding some PDCLib things).

GXTX avatar Jul 03 '20 22:07 GXTX

Hm, I don't have any clue now. I tried your sample code, and everything seemed to work fine, but opening some of the headers that your code include breaks it and makes it claim FILE was not defined, but then opening stdio.h fixes that (until it breaks again), even though I get incorrect errors about size_t in stdio.h.

Somethings broken, but I have no idea what it is.

thrimbor avatar Jul 04 '20 14:07 thrimbor