|
Conditional Inclusion of Files |
Top Previous Next |
You may want to build a single project which would run on several different platforms with different hardware features. In such a case, certain files may not be needed on all platforms (for example, if you have a platform which does not have Wi-Fi, why include Wi-Fi related code?).
While preprocessor directives let you conditionally compile pieces of code within files, you can also conditionally include (or exclude) entire files. This is useful for resource files, which are not processed by the preprocessor and thus may not include preprocessor directives (or rather, you can include whatever you want in them, but it will be treated as "raw resource data" and not be interpreted in any way).
To conditionally include a file, right-click it in the tree and click condition. The following dialog will be shown:

Enter the condition in the form of a preprocessor directive:

The project tree would then show your file with an #if string next to it, to denote that it is conditionally included:
