Question

Is there a pragma-statement for MSVC that causes the compiler to rebuild a file always - also in case it thinks it was just builded?

Was it helpful?

Solution

Here is a trick that I use to achieve this :

1) Add a post build step command with something like

echo #define __FORCE_REBUILD__ "Include this file in a cpp to invalidate it at each compilation" > $(ProjectDir)ForceRebuild.h

2) Add a '#include "ForceRebuild.h"' in each cpp that you want to force rebuild.

It will only work after a build actually occurs (since the post build is skipped if Visual Studio decides to skip building the project).

OTHER TIPS

I doubt there is, and I'm pretty sure there can't be (barring substantial changes to the tool chain in general).

The reason is fairly simple: when make (or equivalent) is deciding what to build, it doesn't look at the content of the file(s) involved at all -- it just compares the timestamp on the object file to the timestamp on the source file. If the object file is newer than its source, the compiler will never be invoked for that file, so the compiler will never get to see the content of that file (including the theorized #pragma) at all.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top