@@ -418,7 +418,7 @@ namespace cppwinrt
418418 {
419419 writer w;
420420 write_preamble (w);
421- w.write (strings::base_macros);
421+ w.write (strings::base_macros, CPPWINRT_VERSION_STRING );
422422 w.flush_to_file (settings.output_folder + " winrt/base_macros.h" );
423423 }
424424
@@ -486,7 +486,11 @@ namespace cppwinrt
486486 w.write (" import winrt.%;\n " , dep);
487487 }
488488
489- w.write (" \n " );
489+ // Version mismatch check: ensure this namespace module was generated by the
490+ // same version of cppwinrt.exe as the winrt_base module it imports.
491+ // winrt::cppwinrt_version is exported from winrt_base; CPPWINRT_VERSION is
492+ // the macro from this module's own base_macros.h in the global module fragment.
493+ w.write (" \n static_assert(winrt::check_version(winrt::cppwinrt_version, CPPWINRT_VERSION), \" Mismatched C++/WinRT headers.\" );\n\n " );
490494
491495 // Include namespace headers in module purview
492496 w.write (" #include \" winrt/impl/%.0.h\"\n " , ns);
@@ -542,7 +546,11 @@ namespace cppwinrt
542546 w.write (" import winrt.%;\n " , dep);
543547 }
544548
545- w.write (" \n " );
549+ // Version mismatch check: ensure this namespace module was generated by the
550+ // same version of cppwinrt.exe as the winrt_base module it imports.
551+ // winrt::cppwinrt_version is exported from winrt_base; CPPWINRT_VERSION is
552+ // the macro from this module's own base_macros.h in the global module fragment.
553+ w.write (" \n static_assert(winrt::check_version(winrt::cppwinrt_version, CPPWINRT_VERSION), \" Mismatched C++/WinRT headers.\" );\n " );
546554
547555 // Forward declarations for all projected types in this SCC.
548556 // This is required because SCC members have cyclic type references,
0 commit comments