Why can't Intellisense find variables from a header file when including it into a namespace?

1

First of all thank you for taking the time to read and maybe answer this.

I want to include a compressed font, which has been converted from a .ttf file into a .h file.

The compressed font is saved (in the .h file) inside an array of the type:

static const unsigned int font_name_compressed_data[about 3 - 10 thousand]

For what I am using (ImGui) this is all fine and I can import the font correctly.

The problem is, when i want to encapsulate those font_name_compressed_data arrays (one for each font) within an namespace, intellisense suddenly stops recognizing them.

It still compiles fine, but intellisense does not work and it constantly shows that there are still errors.


I am using c++17 although i don't think that matters. And I am compiling with Visual Studio 2019, while editing with Visual Studio Code.

Did I do it wrong the first time or is this a bug from intellisense?

~~ E D I T :

My assumption was wrong, after manually opening every font_name.hpp file and individually adding the namespace to it, intellisense was working again. But after closing and reopening it, the same error came back. It is either this

namespace "Fonts" has no member "roboto_compressed_data"

or this

name followed by '::' must be a class or namespace name

seemingly random.

If I autocomplete Fonts:: in Visual Studio 2019 I get all my fonts, but if I do the same thing in Visual Studio Code I dont get any, unless I manually open the font header file in Visual Studio Code and close it again. Also the error comes back after doing Rescan Workspace.

I think I have my project set up right, since I don't get an error anywhere else when using namespaces or includes.

Seems like VS Code just unloads the font header file from memory or something, since it is pretty long, but I don't know...


When i do it like this it does not get recognized:

in the compressed_font.h

static const unsigned int font_name_compressed_data[size of the array] = 
{ 0x0000bc57, 0x00000000, 0x78b30000, ... and so on }

where i then want to use it (.cpp):

namespace font_data
{
  #include "compressed_font.h"
}

// ...

//         v--- This is then unrecognized
font_data::font_name_compressed_data

But after i changed everything to this it got recognized again:

in the compressed_font.h

namespace font_data
{

  static const unsigned int font_name_compressed_data[size of the array] = 
  { 0x0000bc57, 0x00000000, 0x78b30000, ... and so on }

}

where i then want to use it (.cpp):

#include "compressed_font.h"

// ...

//         v--- This is now recognized
font_data::font_name_compressed_data
c++
intellisense
asked on Stack Overflow Jul 29, 2019 by Rico • edited Jul 29, 2019 by Rico

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0