Xcode C++ and folders structure - c++

Is possible force Xcode to create folder, instead only some logical group? I need to do project and have some folder structure, like NET classes in net folder, etc., so then including header files and writing makefile must be compatible with this structure.I don't know how to create real folder in xcode. It creates only some logical groups and sources are in one physical folder, so for example two files, names Connection, can't coexists, even if their classes are in different namespace and they should be in different folders("packages").

Right click, "Add files...", click "New Folder", and select the folder. Will this work for your needs?
Alternatively, just create the folder in the finder and drag it into the source list.
Either way, just make sure you click "Create folder references for any added folders" rather than "Create groups for any added folders".

Related

Using file for different projects from one folder

In my file explorer, my C++ project folders are like this:
... -> Documents -> C++ -> Files . . . . Projects
[In C++ folder, there are two more folders, called Files and one called Projects. I keep all my games/projects in the Projects folder. Each game has its own folder inside.]
Now here's the problem: I want all my common functions (.cpp & .h) to stay in one file folder, so if I ever change it, it changes for all my games. I want to keep these in Files. Is there a way to achieve this, like #include [Directory]? I know I can keep a file in its own game, but I want these to be all changed easily, and my code does not need to be transferred between computers. Thanks
This is not the right way to do it. If you have functionality that is shared between different applications (games, in your case), make a library from them and include that library in all your projects.
Solution for Visual Studio (2017)
For Source Files:
In the solution explorer right click on Sourcefiles and click "Add"/"Add existing" and choose your file(s)
Setting Include directory:
In the solution Explorer right click on your "Project" and click Properties
On the top set "Configuration" to "All Configurations"
Choose in the lsit on the left "VC++ Directories"
Click on the Dropdown arrow on the row with "Include directories" (you might have to click once on the row for the arrow to appear
Click "edit"
Add one line for each include directory. Use the folder icon on the top to open the file explorer to choose the directories

Visual C++, Organize .h and .cpp Files in Folders

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.

How do you create the "Shader" folder in Visual Studio interface

I have seen several projects with the "Shader" folder in the Solution Explorer.
However, when I create one myself, I can only see "Header files", "Source files", "Resource files", and "External dependencies" folder.
Is there a way to tell Visual Studio I need a "Shader" folder because I'm going to use shaders?
If not, how can I create it manually?
Visual Studio has virtual folders called "Filters". These can map to real folders in the file system or you can just use them to define logical/conceptual groups of items inside your projects.
To create a filter under a project in Visual Studio, just right-click with the mouse on your project in the Solution Explorer, expand "Add" and click "New Filter". A new filter ("NewFilter1") will be created under your project which you can then rename as you like.
You can drag items from your project inside it in order to group them "logically" or you can right-click on your new filter and choose Add>Existing Item or Add>New Item. You can even nest multiple filters inside each other.
For example in your case, you would call this filter "Shader" and you can drag-and-drop all shader-related files inside it. This only affects your project and not the directory structure in the file system.
You can still create a "real" folder in the file system and then add files into it, which you can then reference in your project's filter.

Eclipse CDT convert a "normal folder" to a "source folder" or vice versa

Because of me not being used to Eclipse I have projects whose subfolders are mixed "source" and "normal" folders. This is not much of a problem since those are Makefile projects but it bothers me to have my folders not being listed alphabetically (the source folders are displayed first).
I would like to convert my "normal" folders to "source" folders but I can't find anything related in the right click menu on said folders nor in the "properties" window.
Is there a way to convert folder types that doesn't involve editing the .cproject file manually ? If not, can I just edit the sourceEntries tag (it seems to work so far) ?
I am using CDT 8.0.2.
In order to do this in Eclipse, you should get in your project's properties, then expand C/C++ general -> Paths and Symbols -> Sources tab
Then click the Add Folder button, and choose the normal folders you wish to include as "source" folders.
Right click on the folder, "BuildPath" and "Use as Source Folder"

Eclipse CDT: Import source / header files into my new project, without duplicating them

Im sure there is a very simple solution for this.
I have a bunch of .cpp / .h files from a project, say in directory ~/files
On the other hand, I want to create a c++ project using eclipse to work on those files, so I put my workspace on ~/wherever. Then I create a c++ project: ~/wherever/project, and include the source files (located in /~files).
The problem i'm having is that files are now duplicated in ~/wherever/project, and I would like to avoid that, specially so I know which copy of the file to commit.
Is this possible? Im sure it is, but cant get it.
Thanks in advance.
You could try:
creating the project directly above the ~/files (which is not very clean, given the location of the sources in your home dir)
using a linked folder
importing existing sources in your project: details all the options (when your sources are also managed by a VCS like CVS, or when your sources are not managed)
Create a file or folder in your project as per normal (choose File->New->Folder), give it a name, and click on the Advanced button. This reveals a file-choose field where you can browse for the resource you want to "virtually" include in the project. Click Okay and the file/folder you named is now linked outside of the project.