Skip to content

Commit

Permalink
Merge pull request #1115 from luckyCity/master
Browse files Browse the repository at this point in the history
解决win平台 导出头文件在警告等级为W4情况下 编译报错问题.
  • Loading branch information
Qiuwen-chen authored Jun 19, 2024
2 parents 15af3b4 + 5747d35 commit 180bd79
Show file tree
Hide file tree
Showing 18 changed files with 34 additions and 25 deletions.
5 changes: 4 additions & 1 deletion src/common/base/StringView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class WCDB_API UnsafeStringView {
int compare(const UnsafeStringView& other) const;
bool equal(const UnsafeStringView& other) const;

static constexpr size_t npos = -1;
static constexpr size_t npos = std::numeric_limits<size_t>::max();
size_t find(const UnsafeStringView& other) const;

#pragma mark - UnsafeStringView - Operations
Expand Down Expand Up @@ -130,6 +130,9 @@ class WCDB_API UnsafeStringView {
}
};

template<typename T>
struct Convertible<T, std::enable_if_t<std::is_function<T>::value>> : public std::false_type {};

template<typename T, typename Enable = typename std::enable_if<Convertible<T>::value>::type>
UnsafeStringView(const T& t)
{
Expand Down
2 changes: 1 addition & 1 deletion src/common/core/config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Config::~Config() = default;

bool Config::uninvoke(InnerHandle *handle)
{
WCDB_UNUSED(handle)
WCDB_UNUSED(handle);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/core/fts/tokenizer/PinyinTokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void PinyinTokenizer::loadInput(const char *pText, int nText, int flags)
int PinyinTokenizer::nextToken(
const char **ppToken, int *nToken, int *iStart, int *iEnd, int *tflags, int *iPosition)
{
WCDB_UNUSED(iPosition)
WCDB_UNUSED(iPosition);
if (m_flags & FTS5_TOKENIZE_QUERY || m_pinyinTokenArr.size() == m_pinyinTokenIndex) {
while (true) {
int ret = stepNextToken();
Expand Down
4 changes: 3 additions & 1 deletion src/common/core/fts/tokenizer/TokenizerModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ namespace WCDB {

#pragma mark - AbstractFTS5Tokenizer
AbstractFTSTokenizer::AbstractFTSTokenizer(const char *const *azArg, int nArg, void *pCtx){
WCDB_UNUSED(pCtx) WCDB_UNUSED(azArg) WCDB_UNUSED(nArg)
WCDB_UNUSED(pCtx);
WCDB_UNUSED(azArg);
WCDB_UNUSED(nArg);
}

AbstractFTSTokenizer::~AbstractFTSTokenizer()
Expand Down
6 changes: 3 additions & 3 deletions src/common/platform/WCTFileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ StringView FileManager::getTemporaryDirectory()
bool FileManager::setFileProtection(const WCDB::UnsafeStringView &path,
WCDB::FileProtection fileProtection)
{
WCDB_UNUSED(path)
WCDB_UNUSED(fileProtection)
WCDB_UNUSED(path);
WCDB_UNUSED(fileProtection);
return true;
}

Optional<WCDB::FileProtection>
FileManager::getFileProtection(const WCDB::UnsafeStringView &path)
{
WCDB_UNUSED(path)
WCDB_UNUSED(path);
return WCDB::FileProtection::None;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/platform/WCTOperationQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void *OperationQueueForMemory::registerNotificationWhenMemoryWarning()

void OperationQueueForMemory::unregisterNotificationWhenMemoryWarning(void *observer)
{
WCDB_UNUSED(observer)
WCDB_UNUSED(observer);
}

void OperationQueueForMemory::executeOperationWithAutoMemoryRelease(std::function<void(void)> operation)
Expand Down
6 changes: 3 additions & 3 deletions src/common/repair/basic/Crawlable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void Crawlable::safeCrawl(int rootpageno, std::set<int> &crawledInteriorPages, i

void Crawlable::onCellCrawled(const Cell &cell)
{
WCDB_UNUSED(cell)
WCDB_UNUSED(cell);
}

bool Crawlable::canCrawlPage(uint32_t pageno)
Expand All @@ -171,8 +171,8 @@ bool Crawlable::canCrawlPage(uint32_t pageno)

bool Crawlable::willCrawlPage(const Page &page, int height)
{
WCDB_UNUSED(page)
WCDB_UNUSED(height)
WCDB_UNUSED(page);
WCDB_UNUSED(height);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/repair/crawl/SequenceCrawler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void SequenceCrawler::onCrawlerError()

bool SequenceCrawler::willCrawlPage(const Page &page, int height)
{
WCDB_UNUSED(height)
WCDB_UNUSED(height);
m_delegate->onSequencePageCrawled(page);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/repair/factory/Factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ bool Factory::removeDirectoryIfEmpty() const
bool succeed = FileManager::enumerateDirectory(
directory,
[&canRemove](const UnsafeStringView &root, const UnsafeStringView &subpath, bool isDirectory) -> bool {
WCDB_UNUSED(root)
WCDB_UNUSED(root);
if (subpath == restoreDirectoryName || !isDirectory) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/repair/factory/FactoryRetriever.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ bool FactoryRetriever::increaseProgress(const UnsafeStringView &databasePath,
double progress,
double increment)
{
WCDB_UNUSED(progress)
WCDB_UNUSED(progress);
if (useMaterial) {
increment *= 0.5;
}
Expand Down
6 changes: 3 additions & 3 deletions src/common/repair/mechanic/Backup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ bool Backup::willCrawlPage(const Page &page, int height)
markAsInterrupted();
return false;
}
WCDB_UNUSED(height)
WCDB_UNUSED(height);
switch (page.getType()) {
case Page::Type::InteriorTable:
return true;
Expand Down Expand Up @@ -508,7 +508,7 @@ void Backup::onMasterPageCrawled(const Page &page)

void Backup::onMasterCellCrawled(const Cell &cell, const MasterItem &master)
{
WCDB_UNUSED(cell)
WCDB_UNUSED(cell);
if (master.name == Syntax::sequenceTable) {
m_material.info.seqTableRootPage = master.rootpage;
SequenceCrawler crawler;
Expand Down Expand Up @@ -554,7 +554,7 @@ void Backup::onSequencePageCrawled(const Page &page)

void Backup::onSequenceCellCrawled(const Cell &cell, const SequenceItem &sequence)
{
WCDB_UNUSED(cell)
WCDB_UNUSED(cell);
if (sequence.seq == 0) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/repair/parse/PageBasedFileHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ bool PageBasedFileHandle::Cache::shouldPurge() const

void PageBasedFileHandle::Cache::willPurge(const Range& range, const MappedData& data)
{
WCDB_UNUSED(range)
WCDB_UNUSED(range);
m_currentUsedMemery -= data.size();
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/repair/parse/Pager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ bool Pager::Cache::shouldPurge() const

void Pager::Cache::willPurge(const uint32_t& pageNum, const UnsafeData& data)
{
WCDB_UNUSED(pageNum)
WCDB_UNUSED(pageNum);
m_currentUsedMemery -= data.size();
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/utility/Macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
#if !defined(_WIN32)
#define WCDB_UNUSED(variable) _Pragma(WCDB_STRINGIFY(unused(variable)))
#else
#define WCDB_UNUSED(variable)
#define WCDB_UNUSED(variable) (void)(variable)
#endif

#ifdef __clang__
Expand Down
3 changes: 3 additions & 0 deletions src/common/winq/extension/ColumnType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ struct WCDB_API ColumnIsTextType<StringView> : public std::true_type {
const ColumnTypeInfo<ColumnType::Text>::UnderlyingType &t);
};

template<typename T>
struct ColumnIsTextType<T, std::enable_if_t<std::is_function<T>::value>> : public std::false_type {};

//BLOB
template<>
struct WCDB_API ColumnIsBLOBType<std::vector<unsigned char>> : public std::true_type {
Expand Down
2 changes: 1 addition & 1 deletion src/common/winq/extension/ConvertibleImplementation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class LiteralValueConvertible<std::nullptr_t> final : public std::true_type {
public:
static LiteralValue asLiteralValue(const std::nullptr_t& t)
{
WCDB_UNUSED(t)
WCDB_UNUSED(t);
return nullptr;
}
};
Expand Down
5 changes: 3 additions & 2 deletions src/cpp/Operation/StatementOperation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,13 @@ class WCDB_API StatementOperation {
OptionalValueArray<ObjectType> extractAllObjects(const ResultFields& resultFields)
{
OptionalValueArray<ObjectType> result;
bool succeed = false;
while ((succeed = step()) && !done()) {
bool succeed = step();
while (succeed && !done()) {
if (!result.succeed()) {
result = ValueArray<ObjectType>();
}
result->push_back(extractOneObject<ObjectType>(resultFields));
succeed = step();
}
if (!succeed) {
return NullOpt;
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/chaincall/Insert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ class Insert final : public ChainCall<StatementInsert> {
size_t count = getObjectCount();
for (size_t i = 0; i < count; i++) {
const ObjectType& obj = getObjectAtIndex(i);
if (!(succeed = stepOneObject(obj, autoIncrementsOfDefinitions))) {
succeed = stepOneObject(obj, autoIncrementsOfDefinitions);
if (!(succeed)) {
break;
}
}
Expand Down Expand Up @@ -261,7 +262,6 @@ class Insert final : public ChainCall<StatementInsert> {
return *((*m_objSharedPtrArr)[index]);
default:
abort();
return *m_obj;
}
}

Expand Down

0 comments on commit 180bd79

Please sign in to comment.