fnc12 / sqlite_orm

❤️ SQLite ORM light header only library for modern C++
GNU Affero General Public License v3.0
2.27k stars 313 forks source link

Issue: Incorrect Version Macro Check in `sqlite_orm.h` #define _LIBCPP_VERSION #1317

Closed FreeSoaring closed 2 months ago

FreeSoaring commented 3 months ago

Issue: Incorrect Version Macro Check in sqlite_orm.h

Description

The macro check for _LIBCPP_VERSION in sqlite_orm.h is incorrect. The _LIBCPP_VERSION macro is defined in the NDK at $NDK_ROOT/sources/cxx-stl/llvm-libc++/include/__config as follows:

#define _LIBCPP_VERSION 110000

This means that the version number is in the format major * 10000 + minor * 100 + patch.

Problematic Code

In sqlite_orm.h, line 7958, the version check is currently:

#if (__cplusplus >= 202002L) && ((!_LIBCPP_VERSION || _LIBCPP_VERSION >= 13) && (!_GLIBCXX_RELEASE || _GLIBCXX_RELEASE >= 10))

Suggested Fix

The version check should be updated to match the format used by _LIBCPP_VERSION. The corrected macro should be:

#if (__cplusplus >= 202002L) && ((!_LIBCPP_VERSION || _LIBCPP_VERSION >= 130000) && (!_GLIBCXX_RELEASE || _GLIBCXX_RELEASE >= 10))

Rationale

This change ensures that the version comparison for _LIBCPP_VERSION is accurate, reflecting the actual versioning format used by libc++.

Example

The corrected code should be:

#if (__cplusplus >= 202002L) && ((!_LIBCPP_VERSION || _LIBCPP_VERSION >= 130000) && (!_GLIBCXX_RELEASE || _GLIBCXX_RELEASE >= 10))
    // Your code here
#endif
trueqbit commented 3 months ago

Hi @FreeSoaring

  1. Are you sure that the line #define _LIBCPP_VERSION 110000 is correct? @raidenluikang reported in issue #1139 and @lemourin in PR #1183 that _LIBCPP_VERSION was a 5-digit number and that's what I see in the their github repo for v11. They only changed to 6 digits in v16.
  2. I assume you are using sqlite_orm 1.8.2? @lemourin fixed this with PR #1183, which came after 1.8.2 and is in the dev branch.
FreeSoaring commented 3 months ago

你好@FreeSoaring

  1. 您确定该线路#define _LIBCPP_VERSION 110000错了吗?@raidenluikang问题在Android NDK 25上构建错误 #1139中报告了这个问题,@lemourin在 PR Fix 版本中检查保护 std::identity 的使用情况。 #1183_LIBCPP_VERSION一个 5 位数字,这是我在v11 的 github repo 中看到的。他们只在v16中将其改为6位数字。
  2. 我假设我使用 sqlite_orm 1.8.2?@lemourin使用 PR修复版本检查保护 std::identity 用法问题。 #1183,它是在 1.8.2 之后发布的,位于 dev 分支中。

"Oh, I'm sorry, it is indeed a 5-digit number; I typed an extra 0. I am using the source code of sqlite_orm version 1.8.2 downloaded from the Releases section. In the source code, line 7958 uses the _LIBCPP_VERSION to determine if it is a 2-digit number. This can cause compilation issues with the error 'using std::identity; is not defined'. It should be modified to check for a 5-digit version. I manually modified it to:

#if (__cplusplus >= 202002L) && ((!\_LIBCPP\_VERSION || \_LIBCPP\_VERSION >= 13000) && (!\_GLIBCXX\_RELEASE || \_GLIBCXX\_RELEASE >= 10))}

After this change, the NDK compilation completed successfully."

fnc12 commented 2 months ago

@FreeSoaring can we close it now? https://github.com/fnc12/sqlite_orm/pull/1183 is merged

fnc12 commented 2 months ago

I think yes we can. Please feel free to reopen in case of anything