[VS Code] [vscode-cpptools plugin] Intellisense - Dim Inactive Regions: Where does vscode-cpptools get the values for variables used in "#IF" e.g. "GTK_CHECK_VERSION"?

Michael Weghorn m.weghorn at posteo.de
Mon Dec 13 06:38:14 UTC 2021

On 11/12/2021 15.40, Christian Ohrfandl wrote:
> I have the problem that vscode-cpptools "dim inactive regions" option 
> dims the region in the statement
> `#if GTK_CHECK_VERSION(4,0,0)`
> and additionally Intellisense also does not work in that region.
> When changing the statement to
> `#if GTK_CHECK_VERSION(3,0,0)`
> the respective region is not dimmed anymore and also IntelliSense works 
> again.
> However when running the application, the following code
> `cout << gtk_get_major_version() << "." << gtk_get_minor_version() << 
> "." << gtk_get_micro_version() << endl;`
> returns `4.5.0`
> Therefore, I know for a fact that at compile time level my application 
> uses GTK 4.5.0.

What specific source file are you editing?

Are you building both the gtk3 and gtk4 VCL plugins? (gtk3 is enabled by 
default. You can check e.g. whether you have a file 
'instdir/program/libvclplug_gtk3lo.so' after the build, in addition to 

Most of the files in 'vcl/unx/gtk3' are used for both, the gtk3 and the 
gtk4 VCL plugin. (s. how the .cxx files in 'vcl/unx/gtk4/' include the 
ones from the 'vcl/unx/gtk3 directory'; 'vcl/Library_vclplug_gtk3.mk' 
and 'vcl/Library_vclplug_gtk4.mk' are the corresponding Makefiles where 
you can see the compiler flags used).

> So where does the vscode-cpptools know the GTK version from and 
> therefore is able to judge `GTK_CHECK_VERSION(4,0,0)`?

I don't have much experience with VS Code myself, but I'd suppose it 
uses the macro from the corresponding Gtk 3 header (e.g. 
'/usr/include/gtk-3.0/gtk/gtkversion.h' on my Debian testing system).

> I also looked into my project's `.vscode` folder into the 
> `c_cpp_properties.json` file and added the GTK4 library install dir 
> `"/usr/local/include/gtk-4.0"` as follows:
> ```
> {
>      "configurations": [
>          {
>              "name": "Linux",
>              "includePath": [
>                  "${default}",
>                  "/usr/local/include/gtk-4.0",
>                  "/usr/include/gtk-3.0",
>                  "/usr/include/glib-2.0",
>                  "/usr/lib/x86_64-linux-gnu/glib-2.0/include",
>                  "/usr/include/pango-1.0"
>              ],
>              "defines": [],
>              "cStandard": "c17",
>              "intelliSenseMode": "linux-clang-x64"
>          }
>      ],
>      "version": 4
> }

What happens if you drop the Gtk 3 include path "/usr/include/gtk-3.0" 
in addition?
Alternatively, if you don't need the gtk3 VCL plugin, you could also try 
adding '--disable-gtk3' to your 'autogen.input'.

More information about the LibreOffice mailing list