views:

160

answers:

1

I know there are other questions regarding that, and I also know that I can right click on the files that I want excluded, and select Exclude from Project. However. I'm wondering if there are any easy ways of achieving the same purpose programmatically. For example, in a VS project, to link with an external library, I can either add the library name in the project's settings under Linker options, or use "pragma comment(lib, library name in char*)". I'm wondering if this can be achieved similar to how I have described my example.

A: 
#if 0

#endif

Seriously, though... no there's no pragma for that. Even Microsoft isn't quite that silly :P

You can #include a .cpp file to include it without it specifically being part of the project, but your only option to exclude a file is the way you described.

Gerald
This would be the last resort of what I would like to do, as I don't want to wrap the body of the header and source file that I want excluded with similar macros.
stanigator
Header files are not really part of the project, they're only compiled if they're #included. VS just lets you add them to the project as a convenience so you have easy access to open them.If you're wanting to do what I think, and the header is included in other files, the only real option is to enclose both in similar macros like #ifndef _NO_FOO and then add _NO_FOO in your preprocessor directives when you want to exclude them
Gerald