Fix compile errors in c++17

This commit is contained in:
halx99 2023-03-08 08:34:17 +08:00
parent b65b2e1892
commit 8bf4817ff7
16 changed files with 38 additions and 38 deletions

View File

@ -208,7 +208,7 @@ void GridBase::beforeDraw()
renderer->addCommand(groupCommand); renderer->addCommand(groupCommand);
renderer->pushGroup(groupCommand->getRenderQueueID()); renderer->pushGroup(groupCommand->getRenderQueueID());
auto beforeDrawCommandFunc = [=, this]() -> void { auto beforeDrawCommandFunc = [director, renderer, this]() -> void {
_directorProjection = director->getProjection(); _directorProjection = director->getProjection();
set2DProjection(); set2DProjection();
Vec2 size = director->getWinSizeInPixels(); Vec2 size = director->getWinSizeInPixels();
@ -238,7 +238,7 @@ void GridBase::afterDraw(ax::Node* /*target*/)
// renderer->setViewPort(vp.x, vp.y, vp.w, vp.h); // renderer->setViewPort(vp.x, vp.y, vp.w, vp.h);
// renderer->setRenderTarget(_oldRenderTarget); // renderer->setRenderTarget(_oldRenderTarget);
//}; //};
renderer->addCallbackCommand([=, this]() -> void { renderer->addCallbackCommand([director, renderer, this]() -> void {
director->setProjection(_directorProjection); director->setProjection(_directorProjection);
const auto& vp = Camera::getDefaultViewport(); const auto& vp = Camera::getDefaultViewport();
renderer->setViewPort(vp.x, vp.y, vp.w, vp.h); renderer->setViewPort(vp.x, vp.y, vp.w, vp.h);
@ -263,12 +263,12 @@ void GridBase::afterDraw(ax::Node* /*target*/)
// TODO: Director::getInstance()->setProjection(Director::getInstance()->getProjection()); // TODO: Director::getInstance()->setProjection(Director::getInstance()->getProjection());
// TODO: Director::getInstance()->applyOrientation(); // TODO: Director::getInstance()->applyOrientation();
//_beforeBlitCommand.func = [=]() -> void { beforeBlit(); }; //_beforeBlitCommand.func = [=]() -> void { beforeBlit(); };
renderer->addCallbackCommand([=, this]() -> void { beforeBlit(); }); renderer->addCallbackCommand([this]() -> void { beforeBlit(); });
blit(); blit();
//_afterBlitCommand.func = [=]() -> void { afterBlit(); }; //_afterBlitCommand.func = [=]() -> void { afterBlit(); };
renderer->addCallbackCommand([=, this]() -> void { afterBlit(); }); renderer->addCallbackCommand([this]() -> void { afterBlit(); });
} }
// implementation of Grid3D // implementation of Grid3D

View File

@ -654,7 +654,7 @@ void RenderTexture::clearColorAttachment()
auto renderer = _director->getRenderer(); auto renderer = _director->getRenderer();
auto beforeClearAttachmentCommand = renderer->nextCallbackCommand(); auto beforeClearAttachmentCommand = renderer->nextCallbackCommand();
beforeClearAttachmentCommand->init(0); beforeClearAttachmentCommand->init(0);
beforeClearAttachmentCommand->func = [=, this]() -> void { beforeClearAttachmentCommand->func = [this, renderer]() -> void {
_oldRenderTarget = renderer->getRenderTarget(); _oldRenderTarget = renderer->getRenderTarget();
renderer->setRenderTarget(_renderTarget); renderer->setRenderTarget(_renderTarget);
}; };
@ -666,7 +666,7 @@ void RenderTexture::clearColorAttachment()
// auto renderer = _director->getRenderer(); // auto renderer = _director->getRenderer();
auto afterClearAttachmentCommand = renderer->nextCallbackCommand(); auto afterClearAttachmentCommand = renderer->nextCallbackCommand();
afterClearAttachmentCommand->init(0); afterClearAttachmentCommand->init(0);
afterClearAttachmentCommand->func = [=, this]() -> void { renderer->setRenderTarget(_oldRenderTarget); }; afterClearAttachmentCommand->func = [this, renderer]() -> void { renderer->setRenderTarget(_oldRenderTarget); };
renderer->addCommand(afterClearAttachmentCommand); renderer->addCommand(afterClearAttachmentCommand);
} }

View File

@ -859,7 +859,7 @@ std::string LoadObj(std::vector<shape_t>& shapes,
char namebuf[TINYOBJ_SSCANF_BUFFER_SIZE]; char namebuf[TINYOBJ_SSCANF_BUFFER_SIZE];
token += 7; token += 7;
#ifdef _MSC_VER #ifdef _MSC_VER
sscanf_s(token, "%s", namebuf, _countof(namebuf)); sscanf_s(token, "%s", namebuf, (unsigned int)_countof(namebuf));
#else #else
sscanf(token, "%s", namebuf); sscanf(token, "%s", namebuf);
#endif #endif

View File

@ -517,14 +517,14 @@ bool Console::listenOnTCP(int port)
hints.ai_family = AF_UNSPEC; hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) #if defined(_WIN32)
WSADATA wsaData; WSADATA wsaData;
n = WSAStartup(MAKEWORD(2, 2), &wsaData); n = WSAStartup(MAKEWORD(2, 2), &wsaData);
#endif #endif
if ((n = getaddrinfo(nullptr, serv, &hints, &res)) != 0) if ((n = getaddrinfo(nullptr, serv, &hints, &res)) != 0)
{ {
#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) #if defined(_WIN32)
fprintf(stderr, "net_listen error for %s: %s", serv, gai_strerrorA(n)); fprintf(stderr, "net_listen error for %s: %s", serv, gai_strerrorA(n));
#else #else
fprintf(stderr, "net_listen error for %s: %s", serv, gai_strerror(n)); fprintf(stderr, "net_listen error for %s: %s", serv, gai_strerror(n));
@ -561,7 +561,7 @@ bool Console::listenOnTCP(int port)
break; /* success */ break; /* success */
/* bind error, close and try next one */ /* bind error, close and try next one */
#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) #if defined(_WIN32)
closesocket(listenfd); closesocket(listenfd);
#else #else
close(listenfd); close(listenfd);
@ -784,7 +784,7 @@ void Console::loop()
// receive a SIGPIPE, which will cause linux system shutdown the sending process. // receive a SIGPIPE, which will cause linux system shutdown the sending process.
// Add this ioctl code to check if the socket has been closed by peer. // Add this ioctl code to check if the socket has been closed by peer.
#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) #if defined(_WIN32)
u_long n = 0; u_long n = 0;
ioctlsocket(fd, FIONREAD, &n); ioctlsocket(fd, FIONREAD, &n);
#else #else
@ -841,14 +841,14 @@ void Console::loop()
// clean up: ignore stdin, stdout and stderr // clean up: ignore stdin, stdout and stderr
for (const auto& fd : _fds) for (const auto& fd : _fds)
{ {
#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) #if defined(_WIN32)
closesocket(fd); closesocket(fd);
#else #else
close(fd); close(fd);
#endif #endif
} }
#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) #if defined(_WIN32)
closesocket(_listenfd); closesocket(_listenfd);
WSACleanup(); WSACleanup();
#else #else
@ -1244,7 +1244,7 @@ void Console::commandExit(socket_native_type fd, std::string_view /*args*/)
{ {
FD_CLR(fd, &_read_set); FD_CLR(fd, &_read_set);
_fds.erase(std::remove(_fds.begin(), _fds.end(), fd), _fds.end()); _fds.erase(std::remove(_fds.begin(), _fds.end(), fd), _fds.end());
#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) #if defined(_WIN32)
closesocket(fd); closesocket(fd);
#else #else
close(fd); close(fd);
@ -1421,7 +1421,7 @@ void Console::commandTouchSubCommandSwipe(socket_native_type fd, std::string_vie
_touchId = rand(); _touchId = rand();
Scheduler* sched = Director::getInstance()->getScheduler(); Scheduler* sched = Director::getInstance()->getScheduler();
sched->runOnAxmolThread([=, this]() { sched->runOnAxmolThread([x1, y1, this]() {
float tempx = x1, tempy = y1; float tempx = x1, tempy = y1;
Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, &_touchId, &tempx, &tempy); Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, &_touchId, &tempx, &tempy);
}); });
@ -1450,7 +1450,7 @@ void Console::commandTouchSubCommandSwipe(socket_native_type fd, std::string_vie
{ {
_y_ -= dy / dx; _y_ -= dy / dx;
} }
sched->runOnAxmolThread([=, this]() { sched->runOnAxmolThread([_x_, _y_, this]() {
float tempx = _x_, tempy = _y_; float tempx = _x_, tempy = _y_;
Director::getInstance()->getOpenGLView()->handleTouchesMove(1, &_touchId, &tempx, &tempy); Director::getInstance()->getOpenGLView()->handleTouchesMove(1, &_touchId, &tempx, &tempy);
}); });
@ -1477,7 +1477,7 @@ void Console::commandTouchSubCommandSwipe(socket_native_type fd, std::string_vie
{ {
_y_ -= 1; _y_ -= 1;
} }
sched->runOnAxmolThread([=, this]() { sched->runOnAxmolThread([_x_, _y_, this]() {
float tempx = _x_, tempy = _y_; float tempx = _x_, tempy = _y_;
Director::getInstance()->getOpenGLView()->handleTouchesMove(1, &_touchId, &tempx, &tempy); Director::getInstance()->getOpenGLView()->handleTouchesMove(1, &_touchId, &tempx, &tempy);
}); });
@ -1485,7 +1485,7 @@ void Console::commandTouchSubCommandSwipe(socket_native_type fd, std::string_vie
} }
} }
sched->runOnAxmolThread([=, this]() { sched->runOnAxmolThread([x2, y2, this]() {
float tempx = x2, tempy = y2; float tempx = x2, tempy = y2;
Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, &_touchId, &tempx, &tempy); Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, &_touchId, &tempx, &tempy);
}); });

View File

@ -27,7 +27,7 @@
#define __cocos2d_libs__CCController__ #define __cocos2d_libs__CCController__
#if (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID || AX_TARGET_PLATFORM == AX_PLATFORM_IOS || \ #if (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID || AX_TARGET_PLATFORM == AX_PLATFORM_IOS || \
AX_TARGET_PLATFORM == AX_PLATFORM_MAC || AX_TARGET_PLATFORM == AX_PLATFORM_LINUX || \ AX_TARGET_PLATFORM == AX_PLATFORM_MAC || AX_TARGET_PLATFORM == AX_PLATFORM_LINUX || \
AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) defined(_WIN32))
# include "platform/CCPlatformMacros.h" # include "platform/CCPlatformMacros.h"
# include <string> # include <string>

View File

@ -126,14 +126,14 @@ HttpClient::HttpClient()
_service->set_option(yasio::YOPT_S_FORWARD_EVENT, 1); _service->set_option(yasio::YOPT_S_FORWARD_EVENT, 1);
_service->set_option(yasio::YOPT_S_DNS_QUERIES_TIMEOUT, 3); _service->set_option(yasio::YOPT_S_DNS_QUERIES_TIMEOUT, 3);
_service->set_option(yasio::YOPT_S_DNS_QUERIES_TRIES, 1); _service->set_option(yasio::YOPT_S_DNS_QUERIES_TRIES, 1);
_service->start([=, this](yasio::event_ptr&& e) { handleNetworkEvent(e.get()); }); _service->start([this](yasio::event_ptr&& e) { handleNetworkEvent(e.get()); });
for (int i = 0; i < HttpClient::MAX_CHANNELS; ++i) for (int i = 0; i < HttpClient::MAX_CHANNELS; ++i)
{ {
_availChannelQueue.unsafe_emplace_back(i); _availChannelQueue.unsafe_emplace_back(i);
} }
_scheduler->schedule([=, this](float) { dispatchResponseCallbacks(); }, this, 0, false, "#"); _scheduler->schedule([this](float) { dispatchResponseCallbacks(); }, this, 0, false, "#");
_isInited = true; _isInited = true;
} }
@ -159,7 +159,7 @@ void HttpClient::setDispatchOnWorkThread(bool bVal)
_scheduler->unscheduleAllForTarget(this); _scheduler->unscheduleAllForTarget(this);
_dispatchOnWorkThread = bVal; _dispatchOnWorkThread = bVal;
if (!bVal) if (!bVal)
_scheduler->schedule([=, this](float) { dispatchResponseCallbacks(); }, this, 0, false, "#"); _scheduler->schedule([this](float) { dispatchResponseCallbacks(); }, this, 0, false, "#");
} }
void HttpClient::handleNetworkStatusChanged() void HttpClient::handleNetworkStatusChanged()

View File

@ -1114,7 +1114,7 @@ void FileUtils::listFilesRecursively(std::string_view dirPath, std::vector<std::
} }
} }
#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) #if defined(_WIN32)
// windows os implement should override in platform specific FileUtiles class // windows os implement should override in platform specific FileUtiles class
bool FileUtils::isDirectoryExistInternal(std::string_view dirPath) const bool FileUtils::isDirectoryExistInternal(std::string_view dirPath) const
{ {

View File

@ -5,7 +5,7 @@
#include "platform/CCFileStream.h" #include "platform/CCFileStream.h"
#include "platform/CCPlatformConfig.h" #include "platform/CCPlatformConfig.h"
#include <string> #include <string>
#if AX_TARGET_PLATFORM == AX_PLATFORM_WIN32 #if defined(_WIN32)
# include <errno.h> # include <errno.h>
# include <io.h> # include <io.h>
# include <direct.h> # include <direct.h>

View File

@ -43,14 +43,14 @@ public:
{ {
_curEleAttrs.reserve(64); _curEleAttrs.reserve(64);
_sax3Handler.xml_start_element_cb = [=, this](char* name, size_t size) { _sax3Handler.xml_start_element_cb = [this](char* name, size_t size) {
_curEleName = xsxml::string_view(name, size); _curEleName = xsxml::string_view(name, size);
}; };
_sax3Handler.xml_attr_cb = [=, this](const char* name, size_t, const char* value, size_t) { _sax3Handler.xml_attr_cb = [this](const char* name, size_t, const char* value, size_t) {
_curEleAttrs.emplace_back(name); _curEleAttrs.emplace_back(name);
_curEleAttrs.emplace_back(value); _curEleAttrs.emplace_back(value);
}; };
_sax3Handler.xml_end_attr_cb = [=, this]() { _sax3Handler.xml_end_attr_cb = [this]() {
if (!_curEleAttrs.empty()) if (!_curEleAttrs.empty())
{ {
_curEleAttrs.emplace_back(nullptr); _curEleAttrs.emplace_back(nullptr);
@ -66,10 +66,10 @@ public:
(const AX_XML_CHAR**)attrs); (const AX_XML_CHAR**)attrs);
} }
}; };
_sax3Handler.xml_end_element_cb = [=, this](const char* name, size_t len) { _sax3Handler.xml_end_element_cb = [this](const char* name, size_t len) {
SAXParser::endElement(_ccsaxParserImp, (const AX_XML_CHAR*)name); SAXParser::endElement(_ccsaxParserImp, (const AX_XML_CHAR*)name);
}; };
_sax3Handler.xml_text_cb = [=, this](const char* s, size_t len) { _sax3Handler.xml_text_cb = [this](const char* s, size_t len) {
SAXParser::textHandler(_ccsaxParserImp, (const AX_XML_CHAR*)s, len); SAXParser::textHandler(_ccsaxParserImp, (const AX_XML_CHAR*)s, len);
}; };
}; };

View File

@ -40,7 +40,7 @@
#include <sstream> #include <sstream>
#if (AX_TARGET_PLATFORM == AX_PLATFORM_WIN32) #if defined(_WIN32)
# define strcasecmp _stricmp # define strcasecmp _stricmp
#endif #endif

View File

@ -864,7 +864,7 @@ void Renderer::clear(ClearFlag flags, const Color4F& color, float depth, unsigne
CallbackCommand* command = nextCallbackCommand(); CallbackCommand* command = nextCallbackCommand();
command->init(globalOrder); command->init(globalOrder);
command->func = [=, this]() -> void { command->func = [this, flags, color, depth, stencil]() -> void {
backend::RenderPassDescriptor descriptor; backend::RenderPassDescriptor descriptor;

View File

@ -77,7 +77,7 @@ void TextureInfoGL::applySampler(const SamplerDescriptor& descriptor, bool isPow
} }
// apply sampler for all internal textures // apply sampler for all internal textures
foreach ([=, this](GLuint texID, int index) { foreach ([this, target](GLuint texID, int index) {
glBindTexture(target, textures[index]); glBindTexture(target, textures[index]);
setCurrentTexParameters(target); setCurrentTexParameters(target);

View File

@ -295,7 +295,7 @@ void PageView::pageTurningEvent()
void PageView::addEventListener(const ccPageViewCallback& callback) void PageView::addEventListener(const ccPageViewCallback& callback)
{ {
_eventCallback = callback; _eventCallback = callback;
ccScrollViewCallback scrollViewCallback = [=, this](Ref* /*ref*/, ScrollView::EventType type) -> void { ccScrollViewCallback scrollViewCallback = [this](Ref* /*ref*/, ScrollView::EventType type) -> void {
if (type == ScrollView::EventType::AUTOSCROLL_ENDED && _previousPageIndex != _currentPageIndex) if (type == ScrollView::EventType::AUTOSCROLL_ENDED && _previousPageIndex != _currentPageIndex)
{ {
pageTurningEvent(); pageTurningEvent();

View File

@ -248,7 +248,7 @@ void PageViewIndicator::increaseNumberOfPages()
indexNode = Sprite::createWithSpriteFrameName(_indexNodesTextureFile); indexNode = Sprite::createWithSpriteFrameName(_indexNodesTextureFile);
break; break;
default: default:
break; return;
} }
} }

View File

@ -19,7 +19,7 @@
NS_AX_BEGIN NS_AX_BEGIN
#ifdef _WIN32 #if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
# define nxbeep(t) MessageBeep(t) # define nxbeep(t) MessageBeep(t)
#else #else
# define nxbeep(t) # define nxbeep(t)
@ -380,7 +380,7 @@ void TextFieldEx::enableIME(Node* control)
if (control == nullptr) if (control == nullptr)
control = this; control = this;
touchListener->onTouchBegan = [=, this](Touch* touch, Event*) { touchListener->onTouchBegan = [control,this](Touch* touch, Event*) {
bool focus = (engine_inj_checkVisibility(this) && this->editable && this->enabled && bool focus = (engine_inj_checkVisibility(this) && this->editable && this->enabled &&
engine_inj_containsTouchPoint(control, touch)); engine_inj_containsTouchPoint(control, touch));

View File

@ -317,7 +317,7 @@ void AssetsManager::downloadAndUncompress()
// Uncompress zip file. // Uncompress zip file.
if (!uncompress()) if (!uncompress())
{ {
Director::getInstance()->getScheduler()->performFunctionInCocosThread([&, this] { Director::getInstance()->getScheduler()->runOnAxmolThread([&, this] {
UserDefault::getInstance()->setStringForKey(this->keyOfDownloadedVersion().c_str(), ""); UserDefault::getInstance()->setStringForKey(this->keyOfDownloadedVersion().c_str(), "");
UserDefault::getInstance()->flush(); UserDefault::getInstance()->flush();
if (this->_delegate) if (this->_delegate)
@ -326,7 +326,7 @@ void AssetsManager::downloadAndUncompress()
break; break;
} }
Director::getInstance()->getScheduler()->performFunctionInCocosThread([&, this] { Director::getInstance()->getScheduler()->runOnAxmolThread([&, this] {
// Record new version code. // Record new version code.
UserDefault::getInstance()->setStringForKey(this->keyOfVersion().c_str(), this->_version); UserDefault::getInstance()->setStringForKey(this->keyOfVersion().c_str(), this->_version);