aws / aws-sdk-cpp

AWS SDK for C++
Apache License 2.0
1.98k stars 1.06k forks source link

Compile error with aws-sdk-cpp v1.10.53 #2527

Closed eric-ruan-rft closed 1 year ago

eric-ruan-rft commented 1 year ago

Describe the bug

Our development team encountered one compile error when we tried to upgrade aws-sdk-cpp from v1.7.365 to v1.10.53.

We downloaded the source code from https://github.com/aws/aws-sdk-cpp/tree/1.10.53 and followed the instruction to build the SDK v1.10.53 successfully. But we tried to use the SDK header files and libraries to build our application, we encountered one compile error. We are using GCC7.3.1.

Our compile command: cd /tmp/cmake-build/SourceCode/components/TRCEDynamicInstanceManager && /usr/bin/c++ -DAWS_MQTT_WITH_WEBSOCKETS -DAWS_SDK_VERSION_MAJOR=1 -DAWS_SDK_VERSION_MINOR=10 -DAWS_SDK_VERSION_PATCH=53 -DAWS_USE_EPOLL -DBOOST_ERROR_CODE_HEADER_ONLY -DBOOST_SYSTEM_NO_DEPRECATED -DLINUX -DLinux -DNDEBUG -DTRCEDYNAMICINSTANCEMANAGER_EXPORTS -DUSE_IMPORT_EXPORT -D_GLIBCXX_USE_CXX11_ABI=0 -Dtrcedynamicinstancemanager_EXPORTS -I/tmp/cmake-build/SourceCode/components/TRCEDynamicInstanceManager -I/builds/206266/trce-app/trce/SourceCode/components/TRCEDynamicInstanceManager -I/builds/206266/trce-app/trce/SourceCode/includes -I/builds/206266/trce-app/trce/SourceCode/interfaces -I/builds/206266/trce-app/trce/SourceCode/utilities -I/tmp/cmake-build/SourceCode/generated_header -I/root/upalib/src/include -isystem /root/quantum/SourceCode/Includes -isystem /root/quantum/SourceCode/Interfaces -isystem /root/quantum_dependencies -isystem /root/ccl/includes -g -O2 -march=x86-64 -fno-schedule-insns2 -fPIC -Wall -Werror -Wno-unknown-pragmas -fno-delete-null-pointer-checks -fstack-protector -rdynamic -DS2N_KYBER512R3_AVX2_BMI2 -DS2N_STACKTRACE -DS2N_CPUID_AVAILABLE -DS2N_FEATURES_AVAILABLE -fPIC -DS2N_FALL_THROUGH_SUPPORTED -DS2N___RESTRICT__SUPPORTED -DS2N_MADVISE_SUPPORTED -DS2N_CLONE_SUPPORTED -DS2N_LIBCRYPTO_SUPPORTS_EVP_RC4 -pthread -std=gnu++11 -MD -MT SourceCode/components/TRCEDynamicInstanceManager/CMakeFiles/trcedynamicinstancemanager.dir/PoolManager.cpp.o -MF CMakeFiles/trcedynamicinstancemanager.dir/PoolManager.cpp.o.d -o CMakeFiles/trcedynamicinstancemanager.dir/PoolManager.cpp.o -c /builds/206266/trce-app/trce/SourceCode/components/TRCEDynamicInstanceManager/PoolManager.cpp

The error is with include/aws/ecs/model/OSFamily.h. Seems OSFamily cannot be recognized as one legal type inside namespace OSFamilyMapper. We can see below error:

/usr/local/include/aws/ecs/model/OSFamily.h:31:13: error: 'OSFamily' does not name a type
 AWS_ECS_API OSFamily GetOSFamilyForName(const Aws::String& name);

/usr/local/include/aws/ecs/model/OSFamily.h:33:44: error: 'OSFamily' was not declared in this scope
 AWS_ECS_API Aws::String GetNameForOSFamily(OSFamily value);
/usr/local/include/aws/ecs/model/OSFamily.h:33:44: note: suggested alternative:
/usr/local/include/aws/ecs/model/OSFamily.h:16:14: note:   'Aws::ECS::Model::OSFamily'
   enum class OSFamily
/usr/local/include/aws/ecs/model/OSFamily.h:37:1: error: expected declaration before '}' token
 } // namespace Aws

We did not include this OSFamliy directly but just include the ECSClient.h. OSFamily is included by below order.

include/aws/ecs/ECSClient.h
include/aws/ecs/ECSServiceClientModel.h
include/aws/ecs/model/DeregisterTaskDefinitionResult.h
include/aws/ecs/model/TaskDefinition.h
include/aws/ecs/model/RuntimePlatform.h
include/aws/ecs/model/OSFamily.h

Below is the current implementation of OSFamily and namespace OSFamilyMapper:

namespace Aws
{
namespace ECS
{
namespace Model
{
  enum class OSFamily
  {
    NOT_SET,
    WINDOWS_SERVER_2019_FULL,
    WINDOWS_SERVER_2019_CORE,
    WINDOWS_SERVER_2016_FULL,
    WINDOWS_SERVER_2004_CORE,
    WINDOWS_SERVER_2022_CORE,
    WINDOWS_SERVER_2022_FULL,
    WINDOWS_SERVER_20H2_CORE,
    LINUX
  };

namespace OSFamilyMapper
{
AWS_ECS_API OSFamily GetOSFamilyForName(const Aws::String& name);

AWS_ECS_API Aws::String GetNameForOSFamily(OSFamily value);
} // namespace OSFamilyMapper
} // namespace Model
} // namespace ECS
} // namespace Aws

We can see that there is no prefix Aws::ECS::Model:: for "OSFamily". Can you please help to check if anything wrong with the code or do we need to add some special code to ensue GCC can find "OSFamily" from Aws::ECS::Model.

I have tried 1.10.53 to 1.11.94, seems all versions after 1.10.53 have the same error.

If you need more information, please let know.

Expected Behavior

We can compile include/aws/ecs/model/OSFamily.h without any error.

Current Behavior

/usr/local/include/aws/ecs/model/OSFamily.h:31:13: error: 'OSFamily' does not name a type
 AWS_ECS_API OSFamily GetOSFamilyForName(const Aws::String& name);

/usr/local/include/aws/ecs/model/OSFamily.h:33:44: error: 'OSFamily' was not declared in this scope
 AWS_ECS_API Aws::String GetNameForOSFamily(OSFamily value);
/usr/local/include/aws/ecs/model/OSFamily.h:33:44: note: suggested alternative:
/usr/local/include/aws/ecs/model/OSFamily.h:16:14: note:   'Aws::ECS::Model::OSFamily'
   enum class OSFamily
/usr/local/include/aws/ecs/model/OSFamily.h:37:1: error: expected declaration before '}' token
 } // namespace Aws

Reproduction Steps

Include header file include/aws/ecs/ECSClient.h in application and then try to compile the application. I am using GCC 7.3.1.

Possible Solution

Add prefix Aws::ECS::Model:: to "OSFamily".

Additional Information/Context

No response

AWS CPP SDK version used

All versions from 1.10.53 to 1.11.94

Compiler and Version used

gcc 7.3.1

Operating System and version

Amazon Linux 2.0.20230504.1

SergeyRyabinin commented 1 year ago

Ho @eric-ruan-rft ,

This error looks weird. In C++, type will searched in a current namespace, and then in a parent namespace and so on. And in this example, they are even in the same file and class enum declaration is literally few lines above in a parent namespace.

Could you please check that you don't have anything before including SDK headers that could affect headers content, such as #define OSFamily smth or "#define LINUX smth`. This is the only possible reason I can see now. Update: aaand I can see in the list of your compiler arguments:

-DBOOST_SYSTEM_NO_DEPRECATED -DLINUX -DLinux

I'm sorry, our code generation is pretty straightforward and we have this pretty common word LINUX generated as a possible enum value. Is there any option you could remove this compiler definition? Or at least undefine it such as

#if defined(LINUX)
#undef LINUX
#endif

before including SDK headers?

Best regards, Sergey

eric-ruan-rft commented 1 year ago

Hi Sergey,

Thank you for looking into this issue. We have had a try with your suggestion.

Looks like using below can avoid the compile error. We did not notice this “LINUX” inside enum class may conflict with our compile option -DLINUX before.

if defined(LINUX)

undef LINUX

endif

Thanks for pointing out this. However, I am a bit concern about the “LINUX” inside “OSFamily”. Because “-DLINUX” may be widely used. It is better that we can use some other name inside OSFamily as the element.

You can close this issue from your side. Thanks again.

Regards, Eric

From: Sergey Ryabinin @.> Sent: Thursday, June 8, 2023 1:43 PM To: aws/aws-sdk-cpp @.> Cc: Ruan, Eric @.>; Mention @.> Subject: Re: [aws/aws-sdk-cpp] Compile error with aws-sdk-cpp v1.10.53 (Issue #2527)

EXTERNAL EMAIL

Ho @eric-ruan-rfthttps://github.com/eric-ruan-rft ,

This error looks weird. In C++, type will searched in a current namespace, and then in a parent namespace and so on. And in this example, they are even in the same file and class enum declaration is literally few lines above in a parent namespace.

Could you please check that you don't have anything before including SDK headers that could affect headers content, such as #define OSFamily smth or "#define LINUX smth`. This is the only possible reason I can see now. Update: aaand I can see in the list of your compiler arguments:

-DBOOST_SYSTEM_NO_DEPRECATED -DLINUX -DLinux

I'm sorry, our code generation is pretty straightforward and we have this pretty common word LINUX generated as a possible enum value. Is there any option you could remove this compiler definition? Or at least undefine it such as

if defined(LINUX)

undef LINUX

endif

before including SDK headers?

Best regards, Sergey

— Reply to this email directly, view it on GitHubhttps://github.com/aws/aws-sdk-cpp/issues/2527#issuecomment-1581924462, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AX4LNIISMFROFQ6WGLPUGP3XKFQ45ANCNFSM6AAAAAAY6WJBGA. You are receiving this because you were mentioned.Message ID: @.**@.>>

Please read these warnings and restrictions: This e-mail transmission is strictly confidential and intended solely for the ordinary user of the e-mail address to which it was addressed. It may contain legally privileged and/or CONFIDENTIAL information. The unauthorised use, disclosure, distribution and/or copying of this e-mail or any information it contains is prohibited and could, in certain circumstances, constitute a criminal offence. If you have received this e-mail in error or are not an intended recipient please inform London Stock Exchange Group (“LSEG”) immediately by return e-mail or telephone 020 7797 1000. LSEG may collect, process and retain your personal information for its business purposes. For more information please see our Privacy Policy. We advise that in keeping with good computing practice the recipient of this e-mail should ensure that it is virus free. We do not accept responsibility for any virus that may be transferred by way of this e-mail. E-mail may be susceptible to data corruption, interception and unauthorised amendment, and we do not accept liability for any such corruption, interception or amendment or any consequences thereof. Calls to London Stock Exchange Group may be recorded to enable LSEG to carry out its regulatory responsibilities. For more details on the LSEG group of companies click here London Stock Exchange Group plc 10 Paternoster Square London EC4M 7LS Registered in England and Wales No 05369106


github-actions[bot] commented 1 year ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.