Geoff Chappell - Software Analyst
Skipping generation of merged injected text file, cannot write filetype file: 'file': message
This is a level 1 warning, despite being insufficiently important (or too self-evident) for the product documentation to bother listing it.
Compilation of some source file has involved injection of text by an attribute provider. In response to the /Fx option, the compiler has tried to produce an output file, here referred to as a “merged injected text” file, to show both the given source code and the injected source code. Warning C4542 results because the compiler could not create the output file. The filetype placeholder in the message can only be “compiler generated”. The file is the name of the output file, exactly as used by the compiler when attempting the creation. The message placeholder describes the file I/O error (in the limited sense offered by the CRT Library’s strerror function).
For example, create the following fragment
[module (type = "dll", name = "Test")];
as a source file named “test.cpp”, compile with the /Fx option, and confirm that the compiler produces “test.mrg.cpp” as the merged injected file. Now write-protect this output file. Recompile to see the warning (with message resolved as “Permission denied”).
To avoid problems with creating the merged injected text file, it may help to know how file is chosen. The general intention is to form it from the pathname that the compiler uses for the corresponding source file, specifically by inserting “.mrg” between the file name and extension. This much is documented. If there is no extension, then the compiler is coded explicitly just to append “.mrg” to the name.
This last case is subject to a coding error in the compiler. For the purpose of deciding where to insert the “.mrg”, a file extension is understood to begin at the last period in the pathname, not just in the filename at the end of the pathname. If the source file has no extension but is placed in a directory whose path happens to contain a period, then the compiler will insert “.mrg” immediately before the last such period, most likely resulting in an attempt to create the merged injected text file in a directory that does not exist.
For example, create the fragment from earlier as a header file named simply “test” and create a source file named “test.cpp” that contains the line
#include "test"
Put both files in the same directory. Now the source file that produces injected text is the header file “test” and the merged injected text file is expected to be “test.mrg” in the same directory. However, if the path for the directory is, say, “c:\dev.net”, then the compiler tries to create the merged injected text file as “c:\dev.mrg.net\test”, with warning C4542 as the likely outcome in practice.