Visual Studio Code, C/C++ Extension, include renamed path - c++

In the code I have:
#include "xml/XMLParser.h"
While that actual path to the 'XMLParser.h' is:
${workspaceFolder}/lib/XML/XMLParser.h
This folder structure causes VSCode to be unable to match the include (mismatched capitalization), and thus showing a red squiggle underline and not giving me nice intellisense.
Due to a convoluted build process, the directory gets aliased to its lowercase version during build, which then allows the compiler to find the header as written in the code. Thus, is there a way I can tell VSCode to do something similar when searching for matching includes?
I can't rename the folder name nor can I change the include to match the folder since this code is part of a very large project.

Related

Adding libtomcrypt and libtommath to my c++ project

I am a C# developer, and spoiled rotten when it comes to references and dependencies. I am working on a small project now in Visual C++ (Visuial Studio 2017), where I want to use the libtomcrypt and libtommath libraries. I've created a small project and added the 2 projects to my solution:
I have also added my includes:
And I added the dependencies:
However, I still can't build:
Error C1083 Cannot open include file: 'tomcrypt.h': No such file or directory
I am not sure what else I need to do to get the references working and the code to compile. Any pointers is appreciated!
The error message indicates that the compiler can't find the file tomcrypt.h while compiling one of your source files. From the message I would guess that you have a line like the following in your source file:
#include <tomcrypt.h>
(...or perhaps with quotes instead of brackets.) From your screenshot I can see that you've added "...\repos\libtomcrypt-develop\src\headers" to your include path. Is the file tomcrypt.h found directly in that folder, or is it perhaps in a subfolder instead?
Your #include directive will basically append whatever path you give it to each entry in your include path when looking for the file, so if there are subfolders in between, you'll have to expand your #include directive to include those folders.
If this doesn't solve your problem, perhaps try posting the actual full path of where this header file exists on your filesystem, as well as your complete include path value! (The full compiler command from the build log would be useful, as well as the complete error message(s) related to this source file.)
Edit:
The original poster posted a separate answer indicating that the actual problem was that the Visual Studio Project Properties were set correctly, but that he was accidentally trying to build a different Configuration. :(
I was building the project under x86. Once I changed it to x64, it built just fine.

Cppdepend C++ linux base

I'm trying to generate code metrics for a C++ project which is not a Visual Studio one, rather it was written on Linux.
I tried the Project Maker and followed the steps except for the last part (After adding the source files, you can specify the project properties). I did not know what to input. So, I proceeded and when starting the Analysis it gives so many clang parsing errors such as
"string" file not found at "path/xyx.hpp"
fstream file not found at "path/ii.hpp"
though I can see in xyx.hpp that there is a line #include <string>
From the projectmaker configuration you have to specify the include path where the stl library exists. For that right click the project in projectmaker choose properties and added the include path directories separated by ;

FlexLexer.h: No such file or directory flex++

I'm trying to write a program using flex++, however everytime I try to compile I receive the error message:
FlexLexer.h: No such file or directory
However that header is found on the include folder of flex. I don't have problems compiling lex programs for c, however for c++ with flex++ I can't seem to find a way.
I already downloaded flex various times and I don't know if there is a problem with my OS or something like that. My OS is Windows 10.
Thank you
Including should be pretty straightforward once you understand how it works.
Let's look at some different ways you can include a file:
#include "FlexLexer.h"
The quotes tell the compiler to look for the file FlexLexer.h in the same folder as the file being compiled. That is it, it won't look anywhere else.
Now if we change the quotes to brackets:
#include <FlexLexer.h>
This tells the compiler to look for FlexLexer.h in the same folder first, but then if it isn't found it will go through the list of include paths looking for it there, too.
Assuming you are using VisualStudio, there is both a system list of include paths (see Tools > Options > Projects and Solutions > VC++ Directories) and a project list of include paths (right click on the Project in the Solution Explorer, Properties > VC++ Directories). Both of these lists are traversed.
Finally, you can also add subdirectory qualifies to the include, e.g.:
#include "Win\FlexLexer.h"
or
#include <Win\FlexLexer.h>
As you might guess, it looks for the path under either the current directory in the both examples and also under the include path list in the later example. Regardless, the first time the file is found the search will stop and the compiler will use it. So be careful if there are headers will duplicate names in different libraries!

Visual Studio C++ compiler fails because include file name is too long

My application contains multiple sub folders, that can go quite deep, e.g.
library\management\security\descriptor\configurations
(this is just a fictive example)
If another part of my application needs an include file of this folder it writes this:
#include "library\management\security\descriptor\configurations\config.h"
The problem is that if the file that contains this include is also in a quite deep path, like this:
people\groups\interestgroups\manager.cpp
And we have checked out our project in the folder:
E:\jenkins\workspace\application\release\flavour
Then the Visual Studio compiler (we compile using the /I. (slash-I-dot) option) first looks for the file in this location:
E:\jenkins\workspace\application\release\flavour\people\groups\interestgroups\library\management\security\descriptor\configurations\config.h"
And then only in
E:\jenkins\workspace\application\release\flavour\library\management\security\descriptor\configurations\config.h"
(this behavior is described in http://msdn.microsoft.com/en-us/library/vstudio/36k2cdd4(v=vs.100).aspx).
So it insists in looking first in the place where the compiled file is, and then only looking at the /I option.
The problem is that the place where the compiler looks first results in a filename that is too long (>256 characters) and the compiler just gives up.
Is there a way to tell Visual Studio to not stop when an include path is too long? Preferably without using the bracket include format (#include <>).
You can just make file in interestgroups folder that only include config.h file and you just include interestgroups file and use that file

No such file (header file) error

I want to include a header file. I am working in a C++ environment, (C++11, Windows OS, Netbeans 7.3.1 IDE, Cygwin_4.x tool collection). I do not know how I setup the environment/IDE (I did it 6 months ago). I do not understand the fundamentals of the C++ build process or Cygwin related issues either, so I might have to fill in the gaps with some other references/documentation (on what specifically, I'm not sure).
My ultimate objective is to be able to include header files using a syntax that does not require the full file path. I want to write something terse, like:
#include "src\stuff\blah.h" //or even better: #include "blah.h"
The only way I can get my program to compile at all is by using the full file path, like this:
#include "C:\NetBeansProjects\Project1\src\stuff\blah.h"
And, I can only compile once using the full path. If I try to rebuild, it will bomb with the *** multiple target patterns. Stop. error. There are workarounds for this error; those being either 1) deleting the build and dist folders between each rebuild (yikes?), or 2) following this 16 step setup process.
I do not want to follow either of those workarounds because they do not appear to deliver what I want. How can I setup my environment to achieve what I want...of being able to include header files without using full paths?
Thanks to DanielKO for this answer.
In my case, I was able to include with the syntax:
#include "../stuff/blah.h"
I did not have to configure anything under the "Code Assistance" section for the C++ compiler.
All of my code is under "src" as the parent directory in my NetBeans project. It seems that the full path of the file is not required, and the only directory that must be referenced is the lowest level subdirectory (in my case, "stuff").
In NetBeans I've added the path to the list of libraries:
Go to Properties->Select C++->Select 'include libraries'->'Add'
Now: Add the path of the project folder with option "absolute"
Go to Properties->Select C++->Select 'Additional library directories'->'Add'
Now: Add the path of the project folder with option "absolute"
It's very obscure to me why the project doesn't recognize "own" header files.