Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Declarations Hides Local Declarations #6417

Open
3 of 7 tasks
ffreality opened this issue Apr 16, 2024 · 3 comments
Open
3 of 7 tasks

Global Declarations Hides Local Declarations #6417

ffreality opened this issue Apr 16, 2024 · 3 comments

Comments

@ffreality
Copy link

Description

After updating v1.3.9 to v1.4.0 or master branch on Unreal Engine 5.3.2 (C++ 20 enabled), Visual Studio 2022 gives these errors.

Background Information / Reproduction Steps

v1.4.0

1>open62541.c(53138): error C4456: declaration of 'match' hides previous local declaration
1>open62541.c(53079): note: see declaration of 'match'
1>open62541.c(53173): error C4456: declaration of 'match' hides previous local declaration
1>open62541.c(53079): note: see declaration of 'match'
1>open62541.c(242726): error C4456: declaration of 'ret' hides previous local declaration
1>open62541.c(242710): note: see declaration of 'ret'

Master Branch (Commit 10,126)

1>open62541.c(44318): error C4459: declaration of 'hierarchicalRefs' hides global declaration
1>open62541.c(26201): note: see declaration of 'hierarchicalRefs'
1>open62541.c(201758): error C4459: declaration of 'baseEventTypeId' hides global declaration
1>open62541.c(26254): note: see declaration of 'baseEventTypeId'
1>open62541.c(203173): error C4459: declaration of 'baseEventTypeId' hides global declaration
1>open62541.c(26254): note: see declaration of 'baseEventTypeId'
1>open62541.c(203248): error C4459: declaration of 'baseEventTypeId' hides global declaration
1>open62541.c(26254): note: see declaration of 'baseEventTypeId'
1>open62541.c(203291): error C4459: declaration of 'baseEventTypeId' hides global declaration
1>open62541.c(26254): note: see declaration of 'baseEventTypeId'
1>open62541.c(203458): error C4459: declaration of 'baseEventTypeId' hides global declaration
1>open62541.c(26254): note: see declaration of 'baseEventTypeId'

Used CMake options:

UA_MULTITHREADING:STRING=100
MBEDTLS_INCLUDE_DIRS:PATH=D:/Github/C++/OPC/mbedtls/include
MBEDX509_LIBRARY:FILEPATH=D:/Github/C++/OPC/mbedtls/Builds/library/Release/mbedx509.lib
MBEDCRYPTO_LIBRARY:FILEPATH=D:/Github/C++/OPC/mbedtls/Builds/library/Release/mbedcrypto.lib
UA_ENABLE_PUBSUB:BOOL=1
UA_ENABLE_ENCRYPTION_TPM2:STRING=OFF
UA_NAMESPACE_ZERO:STRING=FULL
UA_AMALGAMATION_MULTIARCH:BOOL=1
MBEDTLS_LIBRARY:FILEPATH=D:/Github/C++/OPC/mbedtls/Builds/library/Release/mbedtls.lib
UA_NODESET_DIR:STRING=D:/Github/C++/OPC/UA/open62541/deps/ua-nodeset
CMAKE_BUILD_TYPE:STRING=Release
UA_ENABLE_AMALGAMATION:BOOL=1
UA_ENABLE_PUBSUB_INFORMATIONMODEL:BOOL=1
UA_ENABLE_ENCRYPTION:STRING=MBEDTLS

Checklist

Please provide the following information:

  • open62541 Version (release number or git tag): 1.4.0
  • Other OPC UA SDKs used (client or server):
  • Operating system: Windows 11 23H2
  • Logs (with UA_LOGLEVEL set as low as necessary) attached
  • Wireshark network dump attached
  • Self-contained code example attached
  • Critical issue
@ffreality
Copy link
Author

Adding local_ prefix to local variables seems solves the problem but maybe there is a more suitable fix.

@jpfr
Copy link
Member

jpfr commented Apr 17, 2024

You seem to use a build flag combination that we don't have under test.
Feel free to submit a PR.
You can also add another CI build that uses your settings for the amalgamation build.

@ffreality
Copy link
Author

You seem to use a build flag combination that we don't have under test. Feel free to submit a PR. You can also add another CI build that uses your settings for the amalgamation build.

of course, I can send a PR. btw. did you mean amalgamation multi arch when you say you didn't test it yet ?

Also there was another problem about mbedtls 3.6.0 lts. I fixed it like this.
#6418

ffreality added a commit to FF-Plugins-Active/open62541 that referenced this issue Apr 19, 2024
open62541#6417

As I mentioned on my issue, these local variables create clash with same named global variable and it cause crash with VS2022 - C++ 20 - Unreal Engine 5.

So, I renamed
- local hierarchicalRefs to local_hierarchicalRefs
- local baseEventTypeId to local_baseEventTypeId

```
1>open62541.c(44318): error C4459: declaration of 'hierarchicalRefs' hides global declaration
1>open62541.c(26201): note: see declaration of 'hierarchicalRefs'
1>open62541.c(201758): error C4459: declaration of 'baseEventTypeId' hides global declaration
1>open62541.c(26254): note: see declaration of 'baseEventTypeId'
1>open62541.c(203173): error C4459: declaration of 'baseEventTypeId' hides global declaration
1>open62541.c(26254): note: see declaration of 'baseEventTypeId'
1>open62541.c(203248): error C4459: declaration of 'baseEventTypeId' hides global declaration
1>open62541.c(26254): note: see declaration of 'baseEventTypeId'
1>open62541.c(203291): error C4459: declaration of 'baseEventTypeId' hides global declaration
1>open62541.c(26254): note: see declaration of 'baseEventTypeId'
1>open62541.c(203458): error C4459: declaration of 'baseEventTypeId' hides global declaration
1>open62541.c(26254): note: see declaration of 'baseEventTypeId'
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants