[PATCH] Support for #pragma detect_mismatch

Aaron Ballman aaron at aaronballman.com
Fri May 24 13:27:11 PDT 2013


This patch adds support for MSVC's #pragma detect_mismatch.  This
pragma emits a linker command into the object file which allows the
linker to ensure that there are no inconsistent object files being
linked together.  Eg)

// 1.cpp
#pragma detect_mismatch( "my_library", "1" )

// 2.cpp
#pragma detect_mismatch( "my_library", "2" )

If you link these files together with link.exe, you will get a linker
error (2038) pointing out that the values for my_library do not match.
 However, if 2.cpp had "1" in place of "2", the files would link
together without issue.

For more information, see MSDN:
http://msdn.microsoft.com/en-us/library/ee956429.aspx

The code was modeled after our existing support for passing linker
commands, and makes use of the fact that detect_mismatch uses the
/FAILIFMISMATCH linker option.

~Aaron
-------------- next part --------------
A non-text attachment was scrubbed...
Name: detect_mismatch.patch
Type: application/octet-stream
Size: 17829 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130524/be118a71/attachment.obj>


More information about the cfe-commits mailing list