I don't know how this happened, but I have a project where header and source files are not nicely grouped in "Source Files" and "Header Files" directory in the project hierarchy.
Instead, they all sit directly under the project node.
I tried to manually add these folders, but their icons look different than the usual icons, so I guess that isn't the way to do it.
How could I restore these folders?
They aren't folders per se.
What you're looking for are filters, which help organize code without the need of folders.
They're commonly used for separating header files from implementation files.
Related
When cloning a repo on github I have made with lots of subfolders (like src,include and then several sub-directories in those) on a new PC I get a heap of errors that it can't find the paths for the include files. How do I quickly let Visual Studios know to look for include files in those sub-directories and not just the main folder where I cloned the repo?
Going into properties and choosing "include directories" I can manually select paths to look for include files, but I obviously don't want to manually add the dozens of sub-folders where include files can be found. Preferably I would like whoever is cloning the repo to not have to worry about this at all of course if there is something to do about this when creating the repo. Thank you!
The github repo for reference: https://github.com/OscarUngsgard/Cpp-Monte-Carlo-Value-at-Risk-Engine
And a picture of the "include directories" options I'm refering to in visual studios:
As far as I know there's no way to search for include files in subfolders. And it's obvious if this was possible it would not be relevant to do that as this will take more time to search them.
But you can do one thing, when including files just add their relative path
Such as
#include "../src/header_file.h"
I am very slowly figuring out Code::Blocks and am trying to set it to my liking.
The gentleman that provided the second answer in this post: Organization of files in Code Blocks seems to be able to get C::B to display his header and source files in a single directory in the project tree. This is what his project tree looks like (and how I want mine to look):
However, in my case, anytime I create a header file, C::B displays it in a new directory called 'Headers' (see image below). I should mention that I am keeping the .cpp and .h files together in the same directory when I am creating the files.
I looked all over environment settings, project properties, C::B documentation, online, tried to ask the poster of the link (but i don't have enough reputation to put comments) and I am stuck. Very stuck.
If you know where the setting in C::B which needs to be changed to display the two file types together (like in the link above), I would really appreciate your help.
The Sources and Headers folders that by default appear to contain
respectively the source and header files of a C::B project are virtual
folders that represent the "categories" (header, source) of the files
within.
To disable this virtual organisation of your project:-
Right-click on your project icon in the project workspace
From the pop-menu select Project tree
In the Project tree sub-menu uncheck the item Categorize by file types
I've never had a C++ project that has required organizing stuff in folders before, because I mostly use C# for everything, but now I have this kind of project. What I have done is right click on "Header Files" in the solution explorer, and looked for "Add Folder", but there is no such thing. However, there is something called a "Filter", and it appears to work like a folder, but I don't know if this is how C++ uses folders, or what. Is this the case, using filters as folders, or is there a way to make folders?
Thanks for your help.
You can use filters if you like. These place files into pseudo-folders based on their file extensions. By default, you get header files in "Header Files", source files in "Source Files", etc., but these are customizable, as you've found out.
However, if you prefer the Solution Explorer to reflect the file system, then that is an option as well. Just click the "Show All Files" button at the top of the Solution Explorer to toggle it on. The filters will no longer be active (although they'll still be saved with your project settings so that you can toggle them back on at any time), and you will see the folders exactly as they are in the file system. You can drag-and-drop files between folders, create new folders, and everything, just as you normally would.
(overcompressed JPG image stolen from Ben Williams' blog)
I prefer to keep the filters disabled and see the file system in the Solution Explorer. But I'm a control freakāI like files to be exactly where I put them.
The obvious drawback of this, of course, is that you'll see all files in your solution's directory on disk, even those that have not been added to your project/solution. Those that have not been included will appear grayed out or with a dotted outline, and can be easily included by right-clicking and selecting "Include In Project."
You can add projects to Visual Studio solution. Each project would be in separate folder. They also can be stored hierarchically.
I use XCode 5.1 for C++ development. I have existing code which I add to the project by dragging files from Finder. The project shows all necessary .h and .cpp files. But when I click Build Phases->Compile Sources, I only see sources that from the root directory in my source structure. None of the source files from subdirectories appear in the Compile Sources. Why? And how to fix this?
Also, when I try to add the missing .cpp file from Build Phases->Compile Sources by pressing +, XCode does not expand the subdirectories, so I cannot select the missing .cpp files.
This is unbelievable. The only problem was that I was adding folder structure with Create folder references for any added folders option instead of Create groups for any added folders.
But still don't understand what is the difference in terms of recognition of source files.
Other peculiarity is that you should add resource files in opposite way (Create folder references for any added folders). Otherwise the iOS application does not find the files and does not compile.
I am currently creating a small project over the summer using c++ and visual studio 2010. I wanted to organize the individual .cpp and .h files into their own folders in the project directory. While I use filters in the actual project, I do understand that these are filters, not folders.
So my question is this. In my source, I currently have a header folder called GameStateManger.h, and a folder called Tank_Headers and Tank_CPPs. I also have Tank.h, and Tank.cpp, in their respective folders. My problem is that in GameStateManager, I have this #include "Tank_Headers\Tank.h", however, in my Tank.h, when I type #include... nothing shows up. I cannot find anything. However, if I make a new header, and put it in just source, I can search for those folders. I want to be able to organize my .h files and my .cpp files into individual folders in my source folder, so it is much more organized, considering the project might get very big very soon.
Thank you!
try to use #include "Tank.h"
That should work as long as you add the file to your project first. Drag it from explorer into whatever filter you want it organized it into.
Sorry I forgot to add:
You need to add the subfolder to your project. Go to the project properties, look under C/C++ and add it to Additional Include Folders.