facebook / rocksdb

A library that provides an embeddable, persistent key-value store for fast storage.
http://rocksdb.org
GNU General Public License v2.0
28.52k stars 6.3k forks source link

io_posix.cc:1377 error: comparison of integers of different signs: 'long long' and 'unsigned long long' #10926

Open JMLX42 opened 1 year ago

JMLX42 commented 1 year ago

Expected behavior

The build runs without any warning.

Actual behavior

The following warning is shown (and handled as an error by default) :

io_posix.cc:1377:39: error: comparison of integers of different signs: 'long long' and 'unsigned long long' [-Werror,-Wsign-compare]

Steps to reproduce the behavior

mkdir build
cd build
cmake .. -DANDROID_PLATFORM=android-24 -DANDROID_ABI=armeabi-v7a -DANDROID_STL=c++_shared -DCMAKE_TOOLCHAIN_FILE=/opt/android-ndk-linux/build/cmake/android.toolchain.cmake
akankshamahajan15 commented 1 year ago

@JMLX42 Thanks for reporting it. Do you mind submitting a fix for it.

JMLX42 commented 1 year ago

FYI it happens with android-21 or later. Not before

The problem is most likely related to the fact that for the armv7 target, st_blksize and st_blocks do not have the same type:

https://chromium.googlesource.com/android_tools/+/20ee6d20/ndk/platforms/android-21/arch-arm/usr/include/sys/stat.h#119

  unsigned long st_blksize; \
  unsigned long long st_blocks; \

IMHO the only solution is to cast st_blksize to an unsigned long long when targeting Android. Would that be an acceptable solution @akankshamahajan15 ?