George_E -old
George_E -old

Reputation: 188

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

Upvotes: 0

Views: 200

Answers (2)

pagdot
pagdot

Reputation: 155

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:

  1. In the solution Explorer right click on your "Project" and click Properties
  2. On the top set "Configuration" to "All Configurations"
  3. Choose in the lsit on the left "VC++ Directories"
  4. 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
  5. Click "edit"
  6. Add one line for each include directory. Use the folder icon on the top to open the file explorer to choose the directories

Upvotes: 2

Demosthenes
Demosthenes

Reputation: 1535

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.

Upvotes: 3

Related Questions