Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to organize a C ++ large project in Visual Studio

I would like to separate my source code into folders to have a better organization by grouping the files into directories.

In general there are a lot of .h and .cpp files and I usually go separating the folders. I have always used netbeans, but recently I decided to test Visual Studio.

When starting the code (little thing, to follow a tutorial of creation of games in SDL), I began to organize the source in folders. In Visual Studio when I'm working with C ++ I see the option to add filter, to organize the file structure, but I do not see the option to add folders.

I can organize the code in what visually seems to be a folder structure, but when I go to check the files are a mess, it's all mixed up at the root of the program. Menu options only allow me Add a filter:

Apparently it gets organized, but only visually, the codes all remain in the same place.

I would like to know if inside visual studio there is a way to convert these filters into folders, or how to add the folder through visual studio, because I ended up creating the folders and reorganizing manually.

Not that I usually have files with the same name, but in that environment for example this would be impossible. Besides that I think it gets pretty messy if you look for something, or if you need to switch IDE in the future, because I believe that this logical organization will not be reused in another IDE such as Eclipse, Netbeans and etc.

like image 998
William Avatar asked Dec 29 '18 20:12

William


1 Answers

As you say filters are a purely visual thing, you can organize the files into actual directories using file explorer or when you add a new item to a project you can specify the path where the file will be created. Solution explorer itself does not provide a way to move files on disk.

Note that if you actually use multiple directories you will need to either include part of the path in an #include directive or change the project include search paths so that the file will be found.

like image 145
SoronelHaetir Avatar answered Oct 03 '22 17:10

SoronelHaetir