Skip to content

Commit e73e474

Browse files
committed
first try to make it can be compiled
1 parent 41eabb5 commit e73e474

7 files changed

Lines changed: 68 additions & 4 deletions

File tree

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
all:
2+
$(MAKE) -C apis/CTP all
3+
$(MAKE) -C tests/CPP all

apis/CTP/Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
CXX=clang
2+
IFLAGS=-I../../ -I../../include/ -I../ -I./
3+
CFLAGS=$(IFLAGS)-std=c++11 -fPIC
4+
5+
DEPS=../../../XAPI2/languages/CPP/XAPI_CPP/XApiImpl.o \
6+
../../../XAPI2/languages/CPP/XAPI_CPP/XApiCpp.o \
7+
../../../XAPI2/languages/CPP/XAPI_CPP/XApiC.o \
8+
../../include/toolkit.o
9+
10+
DEPS+=../../common/Queue/MsgQueue.o \
11+
../../common/Queue/RemoteQueue.o \
12+
../../include/ApiProcess.o
13+
14+
LFLAGS=-ldl -L../../include/CTP/linux64 -lthosttraderapi -lthostmduserapi
15+
all: ctp_quote.so ctp_trade.so
16+
17+
%.o: %.cpp
18+
$(CXX) $(CFLAGS) -c $^ -o $@
19+
20+
ctp_quote.so: Quote/main.cpp Quote/MdUserApi.cpp TypeConvert.cpp $(DEPS)
21+
$(CXX) --shared $(IFLAGS) $(CFLAGS) -I../CTP_Quote -o $@ $^
22+
23+
ctp_trade.so: Trade/main.cpp Trade/TraderApi.cpp TypeConvert.cpp $(DEPS)
24+
$(CXX) --shared $(IFLAGS) $(CFLAGS) -I../CTP_Trade -o $@ $^
25+
26+

apis/CTP/Trade/TraderApi.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
#include <cstring>
1919
#include <assert.h>
2020
#include <cfloat>
21+
#if defined(_MSC_VER) || defined(_WIN32)
2122
#include <direct.h>
23+
#endif
2224

2325
#ifdef ENABLE_LICENSE
2426
#include "../../common/License/License.h"
@@ -1499,7 +1501,7 @@ int CTraderApi::_ReqQrySettlementInfo(char type, void* pApi1, void* pApi2, doubl
14991501
CThostFtdcQrySettlementInfoField body = { 0 };
15001502
strncpy(body.BrokerID, m_RspUserLogin.BrokerID, sizeof(TThostFtdcBrokerIDType));
15011503
strncpy(body.InvestorID, m_RspUserLogin.UserID, sizeof(TThostFtdcInvestorIDType));
1502-
sprintf_s(body.TradingDay, "%d", pQuery->DateStart);
1504+
sprintf(body.TradingDay, "%d", pQuery->DateStart);
15031505

15041506
return m_pApi->ReqQrySettlementInfo(&body, ++m_lRequestID);
15051507
}

apis/CTP/TypeConvert.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "stdafx.h"
22
#include "TypeConvert.h"
3-
3+
#include <cstring>
44
#include <stdio.h>
55

66

@@ -352,4 +352,4 @@ void CThostFtdcOrderField_2_OrderField_0(OrderIDType OrderID,CThostFtdcOrderFiel
352352
pOut->ExecType = CThostFtdcOrderField_2_ExecType(pIn);
353353
strcpy(pOut->OrderID, pIn->OrderSysID);
354354
strncpy(pOut->Text, pIn->StatusMsg, sizeof(Char256Type));
355-
}
355+
}

include/toolkit.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ void GetOnFrontDisconnectedMsg(int ErrorId, char* ErrorMsg)
470470
}
471471
}
472472

473+
#if defined _WIN32 || WIN32 || _WINDOWS
473474
void GetDllPathByFunctionName(const char* szFunctionName, char* szPath)
474475
{
475476
HMODULE hModule = nullptr;
@@ -508,3 +509,4 @@ void GetNewPathInSameDirectory(const char* szPath, const char* szFname, const ch
508509
_splitpath(szPath, drive, dir, fname, ext);
509510
_makepath(szFileName, drive, dir, szFname, szExt);
510511
}
512+
#endif

languages/CPP/XAPI_CPP/XApiC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void X_Register(void* pFun, void* pApi, fnOnRespone pCallback, void* pClass)
109109
if (pFun == nullptr || pApi == nullptr)
110110
return;
111111

112-
((fnOnRespone)pFun)(RequestType::RequestType_Register, pApi, nullptr, 0, 0, pCallback, 0, pClass, 0, nullptr, 0);
112+
((fnOnRespone)pFun)(RequestType::RequestType_Register, pApi, nullptr, 0, 0, (void*)pCallback, 0, pClass, 0, nullptr, 0);
113113
}
114114

115115
void X_Connect(void* pFun, void* pApi, const char* szPath, ServerInfoField* pServerInfo, UserInfoField* pUserInfo, int count)

tests/CPP/Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
CXX=clang++
2+
C=clang
3+
IFLAGS=-I../../ -I../../include/ -I../ -I./
4+
CFLAGS=$(IFLAGS)-std=c++11 -fPIC -pthread -g
5+
DEPS=../../languages/CPP/XAPI_CPP/XApiImpl.o \
6+
../../languages/CPP/XAPI_CPP/XApiCpp.o \
7+
../../languages/CPP/XAPI_CPP/XApiC.o \
8+
../../include/toolkit.o
9+
10+
DEPS+=../../common/Queue/MsgQueue.o \
11+
../../common/Queue/RemoteQueue.o \
12+
../../include/ApiProcess.o
13+
14+
LFLAGS=-ldl -L../../include/CTP/linux64 -lthosttraderapi -lthostmduserapi
15+
16+
all: CPP_TEST libQuantBox_CTP_Quote.so libQuantBox_CTP_Trade.so
17+
18+
%.o: %.cpp
19+
$(CXX) $(CFLAGS) -c $^ -o $@
20+
21+
libQuantBox_CTP_Quote.so libQuantBox_CTP_Trade.so:
22+
ln -s ../../apis/CTP/ctp_quote.so libQuantBox_CTP_Quote.so
23+
ln -s ../../apis/CTP/ctp_trade.so libQuantBox_CTP_Trade.so
24+
ln -s ../../include/CTP/linux64/libthosttraderapi.so
25+
ln -s ../../include/CTP/linux64/libthostmduserapi.so
26+
27+
CPP_TEST: CPP_TEST.o $(DEPS)
28+
$(CXX) $(IFLAGS) $(CFLAGS) $(LFLAGS) -I../CTP_Trade -o $@ $^
29+
30+
clean:
31+
rm $(DEPS) *.o

0 commit comments

Comments
 (0)