Skip to content

Commit

Permalink
Clang 17 support - remove clang < 17 support
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanel committed Oct 11, 2023
1 parent e7bbc91 commit fbc0f50
Show file tree
Hide file tree
Showing 25 changed files with 13 additions and 288 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ubuntu-clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
clang-version: [14]
clang-version: [17]
buildmode: [Debug]

steps:
Expand All @@ -28,6 +28,8 @@ jobs:
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{matrix.clang-version}}
sudo apt install clang-tidy-${{matrix.clang-version}}
sudo ln -s /usr/bin/clang-tidy-${{matrix.clang-version}} /usr/local/bin/clang-tidy
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [g++-11, clang++-13]
compiler: [g++-11, clang++-17]
buildmode: [Debug, Release]

steps:
Expand All @@ -26,14 +26,14 @@ jobs:
- name: Install gcc
run: |
sudo apt install ${{matrix.compiler}}
if: matrix.compiler == 'g++-11'
if: startsWith(${{matrix.compiler}}, 'g++')

- name: Install clang
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 13
if: matrix.compiler == 'clang++-13'
sudo ./llvm.sh 17
if: startsWith(${{matrix.compiler}}, 'clang')

- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build
Expand Down
4 changes: 2 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ docker run --mount type=bind,source=<path-to-data-dir-on-host>,target=/app/data

This is a **C++20** project.

It's still currently (as of beginning of 2023) not fully supported by any compiler (although GCC is very close, see [here](https://en.cppreference.com/w/cpp/compiler_support)).
It's still currently (as of beginning of 2023) not fully supported by most compilers (MSVC does, GCC is very close, see [here](https://en.cppreference.com/w/cpp/compiler_support)).

But they have partial support which is sufficient to build `coincenter`.

The following compilers are known to compile `coincenter` (and are tested in the CI):

- **GCC** version >= 11
- **Clang** version >= 14
- **Clang** version >= 17
- **MSVC** version >= 19.30

Other compilers have not been tested.
Expand Down
14 changes: 0 additions & 14 deletions src/api-objects/include/tradeinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,18 @@ struct TradeContext {
};

struct TradeInfo {
#ifndef CCT_AGGR_INIT_CXX20
TradeInfo(const TradeContext &tradeContext, const TradeOptions &opts) : tradeContext(tradeContext), options(opts) {}
#endif

TradeContext tradeContext;
TradeOptions options;
};

struct OrderInfo {
#ifndef CCT_AGGR_INIT_CXX20
explicit OrderInfo(const TradedAmounts &ta, bool closed = false) : tradedAmounts(ta), isClosed(closed) {}
explicit OrderInfo(TradedAmounts &&ta, bool closed = false) : tradedAmounts(std::move(ta)), isClosed(closed) {}
#endif

bool operator==(const OrderInfo &) const = default;

TradedAmounts tradedAmounts;
bool isClosed = false;
};

struct PlaceOrderInfo {
#ifndef CCT_AGGR_INIT_CXX20
PlaceOrderInfo(const OrderInfo &oInfo, const OrderId &orderId) : orderInfo(oInfo), orderId(orderId) {}
PlaceOrderInfo(OrderInfo &&oInfo, OrderId &&orderId) : orderInfo(std::move(oInfo)), orderId(std::move(orderId)) {}
#endif

bool isClosed() const { return orderInfo.isClosed; }
void setClosed() { orderInfo.isClosed = true; }

Expand Down
5 changes: 0 additions & 5 deletions src/api/common/src/exchangepublicapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ namespace {

// Optimized struct containing a currency and a reverse bool to keep market directionality information
struct CurrencyDir {
#ifndef CCT_AGGR_INIT_CXX20
CurrencyDir(CurrencyCode cur, bool isLastRealMarketReversed)
: cur(cur), isLastRealMarketReversed(isLastRealMarketReversed) {}
#endif

CurrencyCode cur;
bool isLastRealMarketReversed;
};
Expand Down
5 changes: 0 additions & 5 deletions src/api/exchanges/include/binanceprivateapi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ class BinancePrivate : public ExchangePrivate {
bool checkMarketAppendSymbol(Market mk, CurlPostData& params);

struct BinanceContext {
#ifndef CCT_AGGR_INIT_CXX20
BinanceContext(CurlHandle& curlHandle, const APIKey& apiKey, BinancePublic& exchangePublic, Duration& queryDelay)
: _curlHandle(curlHandle), _apiKey(apiKey), _exchangePublic(exchangePublic), _queryDelay(queryDelay) {}
#endif

CurlHandle& _curlHandle;
const APIKey& _apiKey;
BinancePublic& _exchangePublic;
Expand Down
27 changes: 0 additions & 27 deletions src/api/exchanges/include/binancepublicapi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ class BinancePublic : public ExchangePublic {
struct ExchangeInfoFunc {
using ExchangeInfoDataByMarket = std::unordered_map<Market, json>;

#ifndef CCT_AGGR_INIT_CXX20
explicit ExchangeInfoFunc(CommonInfo& commonInfo) : _commonInfo(commonInfo) {}
#endif

ExchangeInfoDataByMarket operator()();

CommonInfo& _commonInfo;
Expand All @@ -105,12 +101,6 @@ class BinancePublic : public ExchangePublic {
};

struct MarketsFunc {
#ifndef CCT_AGGR_INIT_CXX20
MarketsFunc(CachedResult<ExchangeInfoFunc>& exchangeInfoCache, CurlHandle& curlHandle,
const ExchangeInfo& exchangeInfo)
: _exchangeInfoCache(exchangeInfoCache), _curlHandle(curlHandle), _exchangeInfo(exchangeInfo) {}
#endif

MarketSet operator()();

CachedResult<ExchangeInfoFunc>& _exchangeInfoCache;
Expand All @@ -119,12 +109,6 @@ class BinancePublic : public ExchangePublic {
};

struct AllOrderBooksFunc {
#ifndef CCT_AGGR_INIT_CXX20
AllOrderBooksFunc(CachedResult<ExchangeInfoFunc>& exchangeInfoCache, CachedResult<MarketsFunc>& marketsCache,
CommonInfo& commonInfo)
: _exchangeInfoCache(exchangeInfoCache), _marketsCache(marketsCache), _commonInfo(commonInfo) {}
#endif

MarketOrderBookMap operator()(int depth);

CachedResult<ExchangeInfoFunc>& _exchangeInfoCache;
Expand All @@ -133,29 +117,18 @@ class BinancePublic : public ExchangePublic {
};

struct OrderBookFunc {
#ifndef CCT_AGGR_INIT_CXX20
explicit OrderBookFunc(CommonInfo& commonInfo) : _commonInfo(commonInfo) {}
#endif

MarketOrderBook operator()(Market mk, int depth = kDefaultDepth);

CommonInfo& _commonInfo;
};

struct TradedVolumeFunc {
#ifndef CCT_AGGR_INIT_CXX20
explicit TradedVolumeFunc(CommonInfo& commonInfo) : _commonInfo(commonInfo) {}
#endif
MonetaryAmount operator()(Market mk);

CommonInfo& _commonInfo;
};

struct TickerFunc {
#ifndef CCT_AGGR_INIT_CXX20
explicit TickerFunc(CommonInfo& commonInfo) : _commonInfo(commonInfo) {}
#endif

MonetaryAmount operator()(Market mk);

CommonInfo& _commonInfo;
Expand Down
5 changes: 0 additions & 5 deletions src/api/exchanges/include/bithumbprivateapi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ class BithumbPrivate : public ExchangePrivate {
friend class BithumbPrivateAPIPlaceOrderTest;

struct DepositWalletFunc {
#ifndef CCT_AGGR_INIT_CXX20
DepositWalletFunc(CurlHandle& curlHandle, const APIKey& apiKey, BithumbPublic& exchangePublic)
: _curlHandle(curlHandle), _apiKey(apiKey), _exchangePublic(exchangePublic) {}
#endif

Wallet operator()(CurrencyCode currencyCode);

CurlHandle& _curlHandle;
Expand Down
19 changes: 0 additions & 19 deletions src/api/exchanges/include/bithumbpublicapi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ class BithumbPublic : public ExchangePublic {
friend class BithumbPrivate;

struct TradableCurrenciesFunc {
#ifndef CCT_AGGR_INIT_CXX20
TradableCurrenciesFunc(const CoincenterInfo& config, CommonAPI& commonAPI, CurlHandle& curlHandle)
: _coincenterInfo(config), _commonAPI(commonAPI), _curlHandle(curlHandle) {}
#endif

CurrencyExchangeFlatSet operator()();

const CoincenterInfo& _coincenterInfo;
Expand All @@ -84,11 +79,6 @@ class BithumbPublic : public ExchangePublic {
};

struct AllOrderBooksFunc {
#ifndef CCT_AGGR_INIT_CXX20
AllOrderBooksFunc(const CoincenterInfo& config, CurlHandle& curlHandle, const ExchangeInfo& exchangeInfo)
: _coincenterInfo(config), _curlHandle(curlHandle), _exchangeInfo(exchangeInfo) {}
#endif

MarketOrderBookMap operator()();

const CoincenterInfo& _coincenterInfo;
Expand All @@ -97,11 +87,6 @@ class BithumbPublic : public ExchangePublic {
};

struct OrderBookFunc {
#ifndef CCT_AGGR_INIT_CXX20
OrderBookFunc(const CoincenterInfo& config, CurlHandle& curlHandle, const ExchangeInfo& exchangeInfo)
: _coincenterInfo(config), _curlHandle(curlHandle), _exchangeInfo(exchangeInfo) {}
#endif

MarketOrderBook operator()(Market mk, int depth);

const CoincenterInfo& _coincenterInfo;
Expand All @@ -110,10 +95,6 @@ class BithumbPublic : public ExchangePublic {
};

struct TradedVolumeFunc {
#ifndef CCT_AGGR_INIT_CXX20
explicit TradedVolumeFunc(CurlHandle& curlHandle) : _curlHandle(curlHandle) {}
#endif

MonetaryAmount operator()(Market mk);

CurlHandle& _curlHandle;
Expand Down
9 changes: 0 additions & 9 deletions src/api/exchanges/include/huobiprivateapi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,13 @@ class HuobiPrivate : public ExchangePrivate {
void cancelOrderProcess(OrderIdView orderId);

struct AccountIdFunc {
#ifndef CCT_AGGR_INIT_CXX20
AccountIdFunc(CurlHandle& curlHandle, const APIKey& apiKey) : _curlHandle(curlHandle), _apiKey(apiKey) {}
#endif

int operator()();

CurlHandle& _curlHandle;
const APIKey& _apiKey;
};

struct DepositWalletFunc {
#ifndef CCT_AGGR_INIT_CXX20
DepositWalletFunc(CurlHandle& curlHandle, const APIKey& apiKey, const HuobiPublic& huobiPublic)
: _curlHandle(curlHandle), _apiKey(apiKey), _huobiPublic(huobiPublic) {}
#endif

Wallet operator()(CurrencyCode currencyCode);

CurlHandle& _curlHandle;
Expand Down
27 changes: 0 additions & 27 deletions src/api/exchanges/include/huobipublicapi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,12 @@ class HuobiPublic : public ExchangePublic {
friend class HuobiPrivate;

struct TradableCurrenciesFunc {
#ifndef CCT_AGGR_INIT_CXX20
explicit TradableCurrenciesFunc(CurlHandle& curlHandle) : _curlHandle(curlHandle) {}
#endif

json operator()();

CurlHandle& _curlHandle;
};

struct MarketsFunc {
#ifndef CCT_AGGR_INIT_CXX20
MarketsFunc(CurlHandle& curlHandle, const ExchangeInfo& exchangeInfo)
: _curlHandle(curlHandle), _exchangeInfo(exchangeInfo) {}
#endif

struct MarketInfo {
VolAndPriNbDecimals volAndPriNbDecimals;

Expand All @@ -112,11 +103,6 @@ class HuobiPublic : public ExchangePublic {
};

struct AllOrderBooksFunc {
#ifndef CCT_AGGR_INIT_CXX20
AllOrderBooksFunc(CachedResult<MarketsFunc>& marketsCache, CurlHandle& curlHandle, const ExchangeInfo& exchangeInfo)
: _marketsCache(marketsCache), _curlHandle(curlHandle), _exchangeInfo(exchangeInfo) {}
#endif

MarketOrderBookMap operator()(int depth);

CachedResult<MarketsFunc>& _marketsCache;
Expand All @@ -125,32 +111,19 @@ class HuobiPublic : public ExchangePublic {
};

struct OrderBookFunc {
#ifndef CCT_AGGR_INIT_CXX20
OrderBookFunc(CurlHandle& curlHandle, const ExchangeInfo& exchangeInfo)
: _curlHandle(curlHandle), _exchangeInfo(exchangeInfo) {}
#endif

MarketOrderBook operator()(Market mk, int depth);

CurlHandle& _curlHandle;
const ExchangeInfo& _exchangeInfo;
};

struct TradedVolumeFunc {
#ifndef CCT_AGGR_INIT_CXX20
explicit TradedVolumeFunc(CurlHandle& curlHandle) : _curlHandle(curlHandle) {}
#endif

MonetaryAmount operator()(Market mk);

CurlHandle& _curlHandle;
};

struct TickerFunc {
#ifndef CCT_AGGR_INIT_CXX20
explicit TickerFunc(CurlHandle& curlHandle) : _curlHandle(curlHandle) {}
#endif

MonetaryAmount operator()(Market mk);

CurlHandle& _curlHandle;
Expand Down
5 changes: 0 additions & 5 deletions src/api/exchanges/include/krakenprivateapi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ class KrakenPrivate : public ExchangePrivate {

private:
struct DepositWalletFunc {
#ifndef CCT_AGGR_INIT_CXX20
DepositWalletFunc(CurlHandle& curlHandle, const APIKey& apiKey, KrakenPublic& exchangePublic)
: _curlHandle(curlHandle), _apiKey(apiKey), _exchangePublic(exchangePublic) {}
#endif

Wallet operator()(CurrencyCode currencyCode);

CurlHandle& _curlHandle;
Expand Down
Loading

0 comments on commit fbc0f50

Please sign in to comment.