Visual C++ Express 2010 suddenly won't accept #includes - c++

I'm working with an API which has #defineed all their include files. I'm developing in Visual C++ 2010 Express, and it's been working fine up till now.
I was adding a new cpp-file to the project, and accidentally added a "Windows Form" instead. VC warned me that my project was not using CLR at the moment, did I really want to? I clicked no, and added the file as intended. After that, however, my project no longer compiles.
The code looks basically like this:
api_header.h:
#define DEFINED_HEADER_NAME "path/to/header/file.h"
stdhpf.h:
#include DEFINED_HEADER_NAME
As I said, worked fine for a long time. Now I get this:
error C2006: '#include' : expected a filename, found 'identifier'
fatal error C1083: Cannot open include file: '': No such file or directory
What is causing this? I found some post that said it was because of having turned on precompiled headers, but I checked Project properties > Configuration properties > C/C++ / Precompiled headers, and it's off (I mention the setting path since I'm new to VS, there might be more than one way to do it...).
Any ideas?

The problem almost certainly lies in the order in which the two statements are pre-processed, rather than having anything to do with inadvertently adding a Windows Form object.
This knowledge base article suggests:
The problem is in using a defined constant to specify an include file in the #include directive. The directive is being processed before the macro is completely expanded, resulting in the error.
The second error seems to confirm this, as it indicates the pre-processor is searching for an include file with an empty name:
fatal error C1083: Cannot open include file: '': No such file or directory

The order of your include files has changed. Perhaps Visual Studio inserted a #include "stdhpf.h" somewhere ahead of your #include "api_header.h".

Disable precompiled headers. It should helps.

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.

Additional include directory in Visual studio 2015 doesn't work

I was trying to re-use an available source code for my own project, it can be found here:
https://github.com/TadasBaltrusaitis/OpenFace
I tried compiling project FeatureExtraction of the original code, everything was fine. Then I created a new empty project and added the following #include:
#include "LandmarkCoreIncludes.h"
#include <Face_utils.h>
#include <FaceAnalyser.h>
#include <GazeEstimation.h>
These are exactly the same as in project FeatureExtraction in the provided source code. I've already changed the additional include directories in C/C++ general tab into:
$(SolutionDir)\lib\local\FaceAnalyser\include
$(SolutionDir)\lib\local\LandmarkDetector\include
However, it still gave me "cannot open source file error".
Update: If I put the absolute path of the header file directly to the code it is OK, however if I put the absolute path to the Additional Include Directories, the error remained.
Use #include "header.h" instead of the one with diamonds (< and >) which looks in another directory.
After that, check if the header files really are in these directories. If they are, you should check the $(SolutionDir) ( I don't use a '\' after the $(SolutionDir) but it may work out as well).
Try to locate and delete the .suo file and restart VS
Looks like I had same "bug" as mentioned in this post here:
Visual Studio does not honor include directories
After having changed the Additional Include Directories for all platforms instead, the code was compiled without any errors.

How do I stop an IntelliSense PCH Warning?

A few of my header files have no includes, so I receive this message in Visual Studio 2010:
IntelliSense: PCH warning: cannot find a suitable header stop location. An intellisense PCH file was not generated.
If I add a single header, for instance:
#include <iostream>
It disappears. How can I stop this error from showing without adding (potentially unused) include>
When adding a .cpp file it inherits the PCH settings of the project.
More detailed explanation of the problem here
Solutions:
Add #pragma once at the start of the file.
It will cause your source file to be included only once in a single compilation, therefore the compiler will be satisfied and won't require additional #include
Setting your project to not use precompiled headers
Disable PCH usage for that one cpp file you've added, which will clear both IntelliSense and compiler warning/error.
Note! I'm including num 2, and 3 because some say it helped, but it only num 1 that did solve my case.
I suppose the problem is that you have precompiled header in your project (by default "stdafx.h") and to correctly solve the problem you should add
#include "stdafx.h"
at start of your header/source file.
Go to project's property and under C/C++ => Precompiled Headers, find the option "Precompiled header".
Change it to "Not Using Precompiled Headers".
Restart Visual Studio (close all active projects).
Nothing helped me except this

error C1083: Cannot open include file: 'stdafx.h': No such file or directory in VS 2005

I am new to visual studio.I have created a simple console application and then selected an empty project of c++.
I have pasted the code form
http://www.cprogramming.com/tutorial/opengl_first_windows_app.html
it is giving the following error
error C1083: Cannot open include file: 'stdafx.h': No such file or directory.
Can any body help me how ti solve that issue.
Also i have pasted the code from
http://www.cprogramming.com/tutorial/opengl_windows_programming.html
and it gives me error in MessageBox function.
Fall in the pit of success by using an appropriate project template. Which is Win32 + Win32 Project, don't tick the "Empty project" option on the property page. You'll get pre-generated code for a Win32 application, take a look at it since you might want to keep parts of it. Or just delete it all past the #include for stdafx.h and replace it with the code you want to try. The stdafx.h file is already pre-cooked for you.
The second snippet probably fails to compile because the code sample is not using Unicode strings. Put an L in front of the string literal, like L"\tHello world".
"stdafx.h" is the default name for the precompiled header in Visual Studio.
If you are not using precompiled headers you can omit that include directive.
See this article on Wikipedia for an explanation of precompiled headers.

what does #include <crtdll/stddef.h> mean?

I am trying to compile the Scintilla control with MSVC++ 2010 Express Edition, and it's quite painful getting it to work right because I need a bunch of files. When compiling SString.h, I noticed this:
#include <crtdll/stddef.h>
I am no C++ programmer, but I do understand what
#include <xxx.h>
means, but what does the the that include mean? I get the following error with it:
Error 1 error C1083: Cannot open include file: 'crtdll/stddef.h': No such file or directory f\scintilla\lexers\sstring.h 44
Any help on how I could fix it would be appreciated.
If I am not mistaken, that is just a relative path. In other words, Visual Studio will look for stddef.h in the crtdll subdirectory of, probably, the root directory of the project.
By using the preceding function, you are summoning, and subsequently inserting a header file into your current source code.
In the case of #include <crtdll/stddef.h> you will be inserting the stddef.h header file from the crtdll directory (which should be a child folder defined in your compiler as the holding pen for header files) during the compilation and linking of your program.
By inserting the stddef.h header file into your source you are giving your program the capability to wield NULL pointer constants, which are exceedingly useful in some of the more advanced programs you may or may not have come across.
Good luck with your program!
I am no C++ programmer, but I do understand what
are you sure?
include with <> searches the include paths for the specified file and copies the content the content of that file in your .cpp.
So you are just missing the crtdll/stddef.h file, however stddef.h actually belongs to the C standardlibrary so you might replace it with #include in C or #include in C++
The easiest way would be to check your include directories. crtdll is the C standard library provided by msvc, so maybe you have to add the parent folder of your standard library include directory
This means that stddef.h needs to be included from the crtdll folder.
You need to check your include directories for Visual C++ projects to see that which are the default directories from where Visual Studio looks up for header files.
To fix this error, see that at which path have you installed the Scintilla control. The crtdll folder will be there most probably. And then, add this folder to your visual studio include directories.
You can set it in the following project properties dialog:
Here http://i56.tinypic.com/2zo9guh.jpg