'byte': ambiguous symbol when building with QT6
-
Hi,
We updated our QT to 6 and building msvc compiler generates this error:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared\rpcndr.h(203): error C2872: 'byte': ambiguous symbol C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared\rpcndr.h(202): note: could be 'unsigned char byte' C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.34.31933\include\cstddef(28): note: or 'std::byte'
Seems like it's an open bug on MSFT "https://developercommunity.visualstudio.com/t/error-c2872-byte-ambiguous-symbol/93889"
How does QT team suggest to handle this?
We don't use byte in our code. -
Hi,
We updated our QT to 6 and building msvc compiler generates this error:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared\rpcndr.h(203): error C2872: 'byte': ambiguous symbol C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared\rpcndr.h(202): note: could be 'unsigned char byte' C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.34.31933\include\cstddef(28): note: or 'std::byte'
Seems like it's an open bug on MSFT "https://developercommunity.visualstudio.com/t/error-c2872-byte-ambiguous-symbol/93889"
How does QT team suggest to handle this?
We don't use byte in our code.Where exactly does it happen? Please provide a minimal, compilable example. Also what Qt version do you use and did try the workarounds mentioned in the bug report?
-
Where exactly does it happen? Please provide a minimal, compilable example. Also what Qt version do you use and did try the workarounds mentioned in the bug report?
@Christian-Ehrlicher Im trying to compile my application using QT6 that is compiled from source.
when i compile my application i get 'byte': ambiguous symbol.
There is a conflict in SDK 10 files and MSVC2022 where are both a requirement by QT website.The workaround worked for me(changing from byte to BYTE in the SDK).
But that will make us do the workaround on all our systems. also when updating the SDK.My question is if QT team knows about this issue and what is their suggestion.
-
@Christian-Ehrlicher Im trying to compile my application using QT6 that is compiled from source.
when i compile my application i get 'byte': ambiguous symbol.
There is a conflict in SDK 10 files and MSVC2022 where are both a requirement by QT website.The workaround worked for me(changing from byte to BYTE in the SDK).
But that will make us do the workaround on all our systems. also when updating the SDK.My question is if QT team knows about this issue and what is their suggestion.
@KJ92 This is not a problem of the Qt code base. You have somewhere in your own project code
byte
defined, That one is now conflicting with the newer SDK.I had this too, once I changed my enum to Byte from byte, it compiled just fine.
-
@Christian-Ehrlicher Im trying to compile my application using QT6 that is compiled from source.
when i compile my application i get 'byte': ambiguous symbol.
There is a conflict in SDK 10 files and MSVC2022 where are both a requirement by QT website.The workaround worked for me(changing from byte to BYTE in the SDK).
But that will make us do the workaround on all our systems. also when updating the SDK.My question is if QT team knows about this issue and what is their suggestion.
@KJ92 said in 'byte': ambiguous symbol when building with QT6:
My question is if QT team knows about this issue and what is their suggestion.
There are at least 4 workarounds suggested in the link you referenced. One of which you seem to have adopted.
But that will make us do the workaround on all our systems. also when updating the SDK.
What are you saying you need to do "when updating the SDK"? If you are saying you have made any change to the supplied header files I see nothing which suggests you do that.
If you are trying to make the minimum change possible the final solution there suggests
#define _HAS_STD_BYTE 0 before any includes: Works ok.
If you do your includes in only one/common place this seems easy if it works.
-
One more thing to consider is that it does find
std::byte
. Do you haveusing namespace std;
somewhere? I am not sure how else it would findstd::byte
. -
@KJ92 This is not a problem of the Qt code base. You have somewhere in your own project code
byte
defined, That one is now conflicting with the newer SDK.I had this too, once I changed my enum to Byte from byte, it compiled just fine.
@J-Hilk said in 'byte': ambiguous symbol when building with QT6:
base. You have somewhere in your own project code byte defined, That one is now conflicting with the newer SDK.
I had this too, once I changed my enum to Byte from byte, it compiled just fine.We don't use byte in our code .
@JonB said in 'byte': ambiguous symbol when building with QT6:
What are you saying you need to do "when updating the SDK"? If you are saying you have made any change to the supplied header files I see nothing which suggests you do that.
One of the suggestion(which is the only solution that resolved my problem) is to change the byte in windows SDK "Windows Kits\10\include\10.0.22621.0\shared\rpcndr.h" file to BYTE.
@JonB said in 'byte': ambiguous symbol when building with QT6:
If you are trying to make the minimum change possible the final solution there suggests
This solution wont work. its disabling byte of the STL and QT is using this byte .
@JonB said in 'byte': ambiguous symbol when building with QT6:
If you do your includes in only one/common place this seems easy if it works.
we have a big project its not possible to do all the includes in one place.
@SimonSchroeder Yes we have the using namestpace std;
but we are not using byte in our code -
@J-Hilk said in 'byte': ambiguous symbol when building with QT6:
base. You have somewhere in your own project code byte defined, That one is now conflicting with the newer SDK.
I had this too, once I changed my enum to Byte from byte, it compiled just fine.We don't use byte in our code .
@JonB said in 'byte': ambiguous symbol when building with QT6:
What are you saying you need to do "when updating the SDK"? If you are saying you have made any change to the supplied header files I see nothing which suggests you do that.
One of the suggestion(which is the only solution that resolved my problem) is to change the byte in windows SDK "Windows Kits\10\include\10.0.22621.0\shared\rpcndr.h" file to BYTE.
@JonB said in 'byte': ambiguous symbol when building with QT6:
If you are trying to make the minimum change possible the final solution there suggests
This solution wont work. its disabling byte of the STL and QT is using this byte .
@JonB said in 'byte': ambiguous symbol when building with QT6:
If you do your includes in only one/common place this seems easy if it works.
we have a big project its not possible to do all the includes in one place.
@SimonSchroeder Yes we have the using namestpace std;
but we are not using byte in our code@KJ92 said in 'byte': ambiguous symbol when building with QT6:
@SimonSchroeder Yes we have the using namestpace std;
but we are not using byte in our codeI am not sure about this, but where do you place that statement relative to the includes of those files? Is it before the
#include
s? If so, can you try moving it to after to see if that resolves? -
@KJ92 said in 'byte': ambiguous symbol when building with QT6:
@SimonSchroeder Yes we have the using namestpace std;
but we are not using byte in our codeI am not sure about this, but where do you place that statement relative to the includes of those files? Is it before the
#include
s? If so, can you try moving it to after to see if that resolves?@JonB said in 'byte': ambiguous symbol when building with QT6:
I am not sure about this, but where do you place that statement relative to the includes of those files? Is it before the #includes? If so, can you try moving it to after to see if that resolves?
In each file we have the using namespace std its after the includes
-
@JonB said in 'byte': ambiguous symbol when building with QT6:
I am not sure about this, but where do you place that statement relative to the includes of those files? Is it before the #includes? If so, can you try moving it to after to see if that resolves?
In each file we have the using namespace std its after the includes
@KJ92
Then I wonder which line of your code compiler is in when it generates:Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared\rpcndr.h(203): error C2872: 'byte': ambiguous symbol
? @Christian-Ehrlicher asked earlier for a minimal compliable example of the error. And that does mean minimal.
-
@KJ92
Then I wonder which line of your code compiler is in when it generates:Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared\rpcndr.h(203): error C2872: 'byte': ambiguous symbol
? @Christian-Ehrlicher asked earlier for a minimal compliable example of the error. And that does mean minimal.
@JonB after i removed all the using namespace std instances from all my code the problem is gone but this means that the library is setting a policy for the program.
Thought about defining my own header in QT sources that will have the definition of byte and then including this header at the beginning of the QT program.
Is this possible? Do you know in which file i need to add this header?