Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliSense cannot open source file

I started working as a research fellow at my university and was instructed to develop a component for an already existing application written in C++ using an in-house framework, also developed in C++.

Currently I am struggling with properly setting up the project in Visual Studio 2017. Whenever I try to include a file from the framework, IntelliSense complains about not being able to open the file.

However, following things add to the oddness of the problem:

  • The solutions properties are set correctly; the project DOES build without any complaints.

  • Writing the '#include'-directive, IntelliSense DOES suggest the correct relative path to the header files (i.e. #include <framework/class.h>).

  • I can open the header file from within the source file referencing it, using the 'Open Document "class.h"' dialog.

I have already came across this:

  • IntelliSense: Cannot open source file in include path
  • Intellisense cannot open source file "*.h"

So far, nothing solved my issue. Did someone come across this issue yet?

TL;DR

  • Everything compiles fine.
  • "C/C++ -> General -> Additional Include Directories" is set properly.
  • "VC++ Directories -> Include Directories" is set as well.
  • IntelliSense properly suggests header file, when writing include directive.
  • BUT IntelliSense reportedly fails to open the file, thus not indexing it.
  • I am stuck with a fancy but resource hungry text editor.

EDIT:

I am working on a MacBook "13 2016; installed Windows 10 Pro 64-bit via Bootcamp.

like image 270
Julian Kirsch Avatar asked Dec 17 '18 12:12

Julian Kirsch


1 Answers

This issue occurs because Windows now has the option for making folders case-sensitive and intellisense has a habit of changing the case of files that it tries to open.

Intellisense tries to use a path like C:\WORKSPACEPATH\PROJECTDIR\MYFILE.cpp (i.e. all uppercase), but if C:\workspace (or any of the other directories in the path) are set to be case-sensitive and don't exactly match, it won't be found.

In my case it was because I created the folder via WSL which enables case sensitivity by default on any new directories it creates (including via things like git clone). See here

Easy Fix

This can be fixed by running the following:

fsutil file setCaseSensitiveInfo <directory> disable

More Commands

You can check whether a folder has case sensitivity enabled by running

fsutil file queryCaseSensitiveInfo <directory>

and Finally, a handy one-liner to disable this recursively:

for /r /d %f in (.) do (fsutil file setCaseSensitiveInfo %f disable)

(This info was originally posted as a comment to the original question, before it turned out it was in fact the same problem. See the comments for input from a couple of other people)

like image 100
yothsoggoth Avatar answered Oct 19 '22 04:10

yothsoggoth