diff --git a/onnxruntime/core/session/onnxruntime_c_api.cc b/onnxruntime/core/session/onnxruntime_c_api.cc index f2a241db27..53af75a2c6 100644 --- a/onnxruntime/core/session/onnxruntime_c_api.cc +++ b/onnxruntime/core/session/onnxruntime_c_api.cc @@ -2728,6 +2728,13 @@ static constexpr OrtApi ort_api_1_to_16 = { &OrtApis::GetBuildInfoString}; // End of Version 15 - DO NOT MODIFY ABOVE (see above text for more information) +// OrtApiBase can never change as there is no way to know what version of OrtApiBase is returned by OrtGetApiBase. +static_assert(sizeof(OrtApiBase) == sizeof(void*) * 2, "New methods can't be added to OrtApiBase as it is not versioned"); +static_assert(offsetof(OrtApiBase, GetApi) / sizeof(void*) == 0, "These functions cannot be reordered"); +static_assert(offsetof(OrtApiBase, GetVersionString) / sizeof(void*) == 1, "These functions cannot be reordered"); +static_assert(std::is_same_v, "This function's signature can never change"); +static_assert(std::is_same_v, "This function's signature can never change"); + // Asserts to do a some checks to ensure older Versions of the OrtApi never change (will detect an addition or deletion but not if they cancel out each other) // If any of these asserts hit, read the above 'Rules on how to add a new Ort API version' static_assert(offsetof(OrtApi, ReleaseCustomOpDomain) / sizeof(void*) == 101, "Size of version 1 API cannot change");