Sfoglia il codice sorgente

Add intellisense configuration for VSCode

kit 1 anno fa
parent
commit
cf54259ff0

BIN
contributing/development/configuring_an_ide/img/vscode_edit_configurations.webp


+ 54 - 0
contributing/development/configuring_an_ide/visual_studio_code.rst

@@ -156,6 +156,60 @@ The name under ``program`` depends on your build configuration,
 e.g. ``godot.linuxbsd.editor.dev.x86_64`` for 64-bit LinuxBSD platform with
 ``platform=editor`` and ``dev_build=yes``.
 
+Configuring Intellisense
+------------------------
+
+For the C/C++ extension:
+
+To fix include errors you may be having, you need to configure some settings in the ``c_cpp_properties.json`` file.
+
+- First, make sure to build the project since some files need to be generated.
+
+- Edit the C/C++ Configuration file either with the UI or with text:
+
+.. figure:: img/vscode_edit_configurations.webp
+   :align: center
+
+- Add an include path for your platform, for example, ``${workspaceFolder}/platform/windows``.
+
+- Add defines for the editor ``TOOLS_ENABLED``, debug builds ``DEBUG_ENABLED``, and tests ``TESTS_ENABLED``.
+
+- Make sure the compiler path is configured correctly to the compiler you are using. See :ref:`doc_introduction_to_the_buildsystem` for further information on your platform.
+
+- The ``c_cpp_properties.json`` file should look similar to this for Windows:
+
+  .. code-block:: js
+
+    {
+      "configurations": [
+        {
+          "name": "Win32",
+          "includePath": [
+            "${workspaceFolder}/**",
+            "${workspaceFolder}/platform/windows"
+          ],
+          "defines": [
+            "_DEBUG",
+            "UNICODE",
+            "_UNICODE",
+            "TOOLS_ENABLED",
+            "DEBUG_ENABLED",
+            "TESTS_ENABLED"
+          ],
+          "windowsSdkVersion": "10.0.22621.0",
+          "compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe",
+          "cStandard": "c17",
+          "cppStandard": "c++17",
+          "intelliSenseMode": "windows-msvc-x64"
+        }
+      ],
+      "version": 4
+    }
+
+- Alternatively, you can use the scons argument ``compiledb=yes`` and set the compile commands setting ``compileCommands`` to ``compile_commands.json``, found in the advanced section of the C/C++ Configuration UI.
+
+  - This argument can be added to your build task in ``tasks.json`` since it will need to be run whenever files are added or moved.
+
 If you run into any issues, ask for help in one of
 `Godot's community channels <https://godotengine.org/community>`__.