Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

detect_mismatch

Places a record in an object. The linker checks these records for potential mismatches.

#pragma detect_mismatch( "name", "value"))

When you link the project, the linker throws a LNK2038 error if the project contains two objects that have the same name but each has a different value. Use this pragma to prevent inconsistent object files from linking.

Both name and value are string literals and obey the rules for string literals with respect to escape characters and concatenation. They are case-sensitive and cannot contain a comma, equal sign, quotation marks, or the null character.

This example creates two files that have different version numbers for the same version label.

// pragma_directive_detect_mismatch_a.cpp
#pragma detect_mismatch("myLib_version", "9")
int main ()
{
   return 0;
}

// pragma_directive_detect_mismatch_b.cpp
#pragma detect_mismatch("myLib_version", "1")

If you compile both of these files by using the command line cl pragma_directive_detect_mismatch_a.cpp pragma_directive_detect_mismatch_b.cpp, you will receive the error LNK2038.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.