Skip to content

Commit

Permalink
Add ABI version mismatch warning in InitAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyRyabinin committed Sep 21, 2023
1 parent 9f9ac5f commit b054124
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/aws-cpp-sdk-core/include/aws/core/Aws.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ namespace Aws
* Basic usage can be found in aws-cpp-sdk-core-tests/monitoring/MonitoringTest.cpp
*/
MonitoringOptions monitoringOptions;

struct SDKVersion
{
unsigned char major = AWS_SDK_VERSION_MAJOR;
unsigned char minor = AWS_SDK_VERSION_MINOR;
unsigned short patch = AWS_SDK_VERSION_PATCH;
} sdkVersion;
};

/*
Expand Down
15 changes: 15 additions & 0 deletions src/aws-cpp-sdk-core/source/Aws.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,21 @@ namespace Aws
Aws::Internal::InitEC2MetadataClient();
Aws::Monitoring::InitMonitoring(options.monitoringOptions.customizedMonitoringFactory_create_fn);
Aws::Utils::ComponentRegistry::InitComponentRegistry();

if(options.sdkVersion.major != AWS_SDK_VERSION_MAJOR ||
options.sdkVersion.minor != AWS_SDK_VERSION_MINOR ||
options.sdkVersion.patch != AWS_SDK_VERSION_PATCH)
{
AWS_LOGSTREAM_ERROR(ALLOCATION_TAG, "AWS-SDK-CPP version mismatch detected.");
AWS_LOGSTREAM_INFO(ALLOCATION_TAG, "Initialized AWS-SDK-CPP with version "
<< AWS_SDK_VERSION_MAJOR << "." << AWS_SDK_VERSION_MINOR << "." << AWS_SDK_VERSION_PATCH << "; "
<< "However, the caller application had been built for AWS-SDK-CPP version "
<< (int) options.sdkVersion.major << "."
<< (int) options.sdkVersion.minor << "."
<< (int) options.sdkVersion.patch << "; "
<< "ABI is not guaranteed, please don't mix different versions of built libraries "
<< "and different versions of headers and corresponding built libraries.");
}
}

void ShutdownAPI(const SDKOptions& options)
Expand Down

0 comments on commit b054124

Please sign in to comment.