"Byte was not declared in this scope" Trying to add c++ file

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

"Byte was not declared in this scope" Trying to add c++ file

ソリューションへジャンプ
1,458件の閲覧回数
pb632146
Contributor V

I am trying to bring in c++ code from another project into a new one, but it is not recognizing "byte"s, The dialect is on c++17 so what should I do? I don't really want to convert everything to unsigned char

pb632146_1-1736576872192.png

pb632146_2-1736576976078.png

 

0 件の賞賛
返信
1 解決策
1,368件の閲覧回数
pb632146
Contributor V
Okay so it turns out that I should have noted that this is arduino code I am porting from , which uses byte as "uint8_t." Thank you for the help though it turns out that using the actual cstddef would be incorrect in this situation.

元の投稿で解決策を見る

0 件の賞賛
返信
4 返答(返信)
1,420件の閲覧回数
pb632146
Contributor V

Any suggestion on what to do to make the compiler see byte?

0 件の賞賛
返信
1,398件の閲覧回数
james246henry
Contributor I

Hello @pb632146,
In C++17, std::byte was introduced as part of the standard library to represent raw byte data. If your code isn't recognizing byte, ensure you are including the correct header:

cpp
#include <cstddef> // for std::byte

By including this header, your project should properly recognize std::byte. This eliminates the need to convert every instance to unsigned char.


Best Regards,
James Henry

0 件の賞賛
返信
1,396件の閲覧回数
pb632146
Contributor V
I see, do I need to add std:: on to all the byte declarations? or is there a define I can do to avoid finding and adding every instance of byte
0 件の賞賛
返信
1,369件の閲覧回数
pb632146
Contributor V
Okay so it turns out that I should have noted that this is arduino code I am porting from , which uses byte as "uint8_t." Thank you for the help though it turns out that using the actual cstddef would be incorrect in this situation.
0 件の賞賛
返信