You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is based on feedback from Compiling bfx-cpp-api - Byte datatype undeclared on Stack Overflow. When using the current Crypto++ Master and soon to be Crypto++ 6.0, we moved our byte definition into the CryptoPP namespace.
The move was necessary because of C++17's std::byte and Microsoft's byte which is also in the global namespace. C++17 ensured something was going to break, so we stepped out of the way of the train and did what we were supposed to do years ago (namely, placed byte in our namespace). Now Microsoft SDKs are the one that's going to break things when it collides with C++17. Also see Crypto++ Issue 442 on the Crypto++ bug tracker and std::byte in the Crypto++ wiki.
The short of it for BFX-API is, you can do the following if you want to preserve old behavior. But keep in mind this is going to move the problem from Crypto++ to BFX-API:
// CRYPTOPP_NO_GLOBAL_BYTE signals byte is at CryptoPP::byte
#if defined(CRYPTOPP_NO_GLOBAL_BYTE)
typedef unsigned char byte;
#endif
You could also perform the following which produces a similar effect:
// CRYPTOPP_NO_GLOBAL_BYTE signals byte is at CryptoPP::byte
#if defined(CRYPTOPP_NO_GLOBAL_BYTE)
using CryptoPP::byte;
#endif
When we moved the Crypto++ byte to CryptoPP::byte we added the define CRYPTOPP_NO_GLOBAL_BYTE so downstream had a signal for remediations like above.
Here is a test using example.cpp from BFX-API. In the test, Crypto++ and BFX are side-by-side, so there is a bfx/ folder and a cryptopp/ folder.
$ g++ BitfinexAPI.cpp example.cpp -I ../ ../cryptopp/libcryptopp.a -o example.exe
BitfinexAPI.cpp: In static member function ‘static int BitfinexAPI::getBase64(const string&, std::__cxx11::string&)’:
BitfinexAPI.cpp:936:5: error: ‘byte’ was not declared in this scope
byte buffer[1024] = {};
^~~~
BitfinexAPI.cpp:936:5: note: suggested alternative:
In file included from ../cryptopp/seckey.h:9:0,
from ../cryptopp/hmac.h:9,
from BitfinexAPI.cpp:37:
../cryptopp/config.h:222:23: note: ‘CryptoPP::byte’
typedef unsigned char byte;
^~~~
BitfinexAPI.cpp:940:9: error: ‘buffer’ was not declared in this scope
buffer[i] = content[i];
^~~~~~
BitfinexAPI.cpp:940:9: note: suggested alternative: ‘setbuffer’
buffer[i] = content[i];
^~~~~~
setbuffer
BitfinexAPI.cpp:943:21: error: ‘buffer’ was not declared in this scope
StringSource ss(buffer, content.length(), true, new Base64Encoder( new StringSink(encoded), false));
^~~~~~
BitfinexAPI.cpp:943:21: note: suggested alternative: ‘setbuffer’
StringSource ss(buffer, content.length(), true, new Base64Encoder( new StringSink(encoded), false));
^~~~~~
setbuffer
BitfinexAPI.cpp: In static member function ‘static int BitfinexAPI::getHmacSha384(const string&, const string&, std::__cxx11::string&)’:
BitfinexAPI.cpp:963:33: error: ISO C++ forbids declaration of ‘type name’ with no type [-fpermissive]
SecByteBlock byteKey((const byte*)key.data(), key.size());
^~~~
BitfinexAPI.cpp:963:27: error: expected primary-expression before ‘const’
SecByteBlock byteKey((const byte*)key.data(), key.size());
^~~~~
BitfinexAPI.cpp:963:27: error: expected ‘)’ before ‘const’
The text was updated successfully, but these errors were encountered:
This is based on feedback from Compiling bfx-cpp-api - Byte datatype undeclared on Stack Overflow. When using the current Crypto++ Master and soon to be Crypto++ 6.0, we moved our
byte
definition into theCryptoPP
namespace.The move was necessary because of C++17's
std::byte
and Microsoft'sbyte
which is also in the global namespace. C++17 ensured something was going to break, so we stepped out of the way of the train and did what we were supposed to do years ago (namely, placedbyte
in our namespace). Now Microsoft SDKs are the one that's going to break things when it collides with C++17. Also see Crypto++ Issue 442 on the Crypto++ bug tracker and std::byte in the Crypto++ wiki.The short of it for BFX-API is, you can do the following if you want to preserve old behavior. But keep in mind this is going to move the problem from Crypto++ to BFX-API:
You could also perform the following which produces a similar effect:
When we moved the Crypto++ byte to
CryptoPP::byte
we added the defineCRYPTOPP_NO_GLOBAL_BYTE
so downstream had a signal for remediations like above.Here is a test using
example.cpp
from BFX-API. In the test, Crypto++ and BFX are side-by-side, so there is abfx/
folder and acryptopp/
folder.The text was updated successfully, but these errors were encountered: