Ask the Expert

Can I have multiple source files listed in a single solution?

My environment is C/C++ under VS.NET 2003 edition.

I port games amongst cell phone handsets; part of the testing is building a DLL that runs on a PC-based emulator. Each game has several source files. I also have a file from the SDK I need to include with each build. I have two SDK versions. So I need either c:/vendor/version_1/src/foo.c or c:/vendor/version_2/src/foo.c. Foo.c never changes, so I want to build it out of the vendor's SDK distribution.

I also need to include header files from either c:/vendor/version_1/inc, or c:/vendor/version_2/inc.

Right now I have one solution per game, with several configurations to deal with the handsets. It works very well except for that pesky foo.c file.

Ideally, I'd like to have a single variable, $(VERSION) or some such, and key the SRC and INC directories off this. If that isn't possible, can I somehow have multiple source file listed in a single solution?

If all else fails, I can use a pre-build rule to copy the foo.c file to the local directory, and a post build rule to delete the silly thing. This seems, well, silly.
Here's an idea: why not create a file in your project called MYFOO.C that only consists of a single line that looks like this:

#include <foo.c>
Then, each configuration has a different include directory for foo.c based on the version (which you already do for the header files).

This was first published in May 2004

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: