4

The VS-IDE will write //{{NO_DEPENDENCIES}} to resource header files. This comment is actually a feature that prevents (unnecessary) rebuilding of cpp files that include the resource header.

But, like stated in the MSDN, this can lead to "undesirable side-effects".

In our project we do have the resource.h included in the stdafx.h for pre-compilation. Unfortunately the precompiled header is not rebuild, if the resource file changes...

If the NO_DEPENDENCIES is removed, it works (but it's written again, if resources are changed via IDE).

Is there a way to prevent the IDE from writing //{{NO_DEPENDENCIES}} to the resource.h file every time the file was changed?

I think the best way would be to exclude the resource.h from the precompiled header file and re-include them in the needed .h and .cpp files. This way only the affected files would need to be (manually!) rebuild and not all files (which would happen, if the pch is recompiled).

Any comments?

4

1 回答 1

1

我同意您自己的建议:该resource.h文件可能不应该是预编译头文件的一部分。

请注意,如果应用此建议导致编译时间过长,您可以尝试使用两个预编译的头文件:一侧是当前 resource.h,另一侧是当前的。后一种 PCH 将仅由需要resource.h.

可能不太容易维护,虽然......

于 2009-10-21T19:14:31.943 回答