Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: comparison of integer expressions of different signedness #1231

Open
dkbattle opened this issue Aug 1, 2022 · 3 comments
Open

error: comparison of integer expressions of different signedness #1231

dkbattle opened this issue Aug 1, 2022 · 3 comments

Comments

@dkbattle
Copy link

dkbattle commented Aug 1, 2022

In the QuantUtilsTest.cc on line 641 I am getting the error "error: comparison of integer expressions of different signedness: ‘std::vector::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Werror=sign-compare]
[build] 641 | assert(float_test_input.size() == row * col);"

If any assistance can be provided, that would be awesome!

@jianyuh
Copy link
Member

jianyuh commented Aug 16, 2022

Which compiler version did you use and do you have more detailed repro? Thanks!

@Llcoolsouder
Copy link

I recently had the same error message using clang. Switching to g++ seemed to fix the issue. @dkbattle

@sneurlax
Copy link

sneurlax commented Dec 13, 2022

I get same on v4.3.4 (v4.3.1 is fine) from a different test:

In file included from ./external/unity/unity.h:16,
                 from tests/testutil_unity.hpp:36,
                 from tests/testutil.cpp:30:
tests/testutil.cpp: In function 'fd_t connect_socket(const char*, int, int)':
./external/unity/unity.h:134:130: error: comparison of integer expressions of different signedness: 'int' and 'const fd_t' {aka 'const long long unsigned int'} [-Werror=sign-compare]
  134 | #define TEST_ASSERT_NOT_EQUAL(expected, actual)                                                    UNITY_TEST_ASSERT(((expected) !=  (actual)), __LINE__, " Expected Not-Equal")
      |                                                                                                                       ~~~~~~~~~~~^~~~~~~~~~~~
./external/unity/unity_internals.h:654:102: note: in definition of macro 'UNITY_TEST_ASSERT'
  654 | #define UNITY_TEST_ASSERT(condition, line, message)                                              if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message));}
      |                                                                                                      ^~~~~~~~~
tests/testutil.cpp:389:5: note: in expansion of macro 'TEST_ASSERT_NOT_EQUAL'
  389 |     TEST_ASSERT_NOT_EQUAL (-1, s_pre);
      |     ^~~~~~~~~~~~~~~~~~~~~
tests/testutil.cpp: In function 'fd_t bind_socket_resolve_port(const char*, const char*, char*, int, int)':
./external/unity/unity.h:134:130: error: comparison of integer expressions of different signedness: 'int' and 'const fd_t' {aka 'const long long unsigned int'} [-Werror=sign-compare]
  134 | #define TEST_ASSERT_NOT_EQUAL(expected, actual)                                                    UNITY_TEST_ASSERT(((expected) !=  (actual)), __LINE__, " Expected Not-Equal")
      |                                                                                                                       ~~~~~~~~~~~^~~~~~~~~~~~
./external/unity/unity_internals.h:654:102: note: in definition of macro 'UNITY_TEST_ASSERT'
  654 | #define UNITY_TEST_ASSERT(condition, line, message)                                              if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message));}
      |                                                                                                      ^~~~~~~~~
tests/testutil.cpp:446:5: note: in expansion of macro 'TEST_ASSERT_NOT_EQUAL'
  446 |     TEST_ASSERT_NOT_EQUAL (-1, s_pre);
      |     ^~~~~~~~~~~~~~~~~~~~

I am building zmq like:

#!/bin/bash

export SCRIPTDIR="$(pwd)"
export WORKDIR=${SCRIPTDIR}/build
export TYPES_OF_BUILD="x86_64"
export PREFIX=$WORKDIR/prefix_${TYPES_OF_BUILD}
export HOST=x86_64-w64-mingw32

ZMQ_SRC_DIR=$WORKDIR/libzmq
ZMQ_BRANCH=v4.3.4
ZMQ_COMMIT_HASH=4097855ddaaa65ed7b5e8cb86d143842a594eebd

cd $WORKDIR
rm -rf $ZMQ_SRC_DIR
git clone https://github.com/zeromq/libzmq.git ${ZMQ_SRC_DIR} -b ${ZMQ_BRANCH}
cd $ZMQ_SRC_DIR
git checkout ${ZMQ_COMMIT_HASH}
./autogen.sh

./configure \
	--without-documentation \
	--without-docs \
	--disable-shared \
	--disable-curve \
	--prefix=${PREFIX} \
	--host=${HOST} \
	--enable-static \
	--with-pic \
	define=ZMQ_STATIC\
	CFLAGS="-Wall -Wno-pedantic-ms-format -DLIBCZMQ_EXPORTS -DZMQ_DEFINED_STDINT" \
	LDFLAGS="-lws2_32 -liphlpapi -lrpcrt4" #-L/usr/x86_64-w64-mingw32/lib \
	#--without-libsodium \
make CROSS=x86_64-w64-mingw32.static- -j$THREADS
make install

# See http://vrecan.github.io/post/crosscompile_go_zeromq/
# See https://stackoverflow.com/questions/21322707/zlib-header-not-found-when-cross-compiling-with-mingw

Again, downgrading to v4.3.1 is a workaround for this issue.

sneurlax added a commit to sneurlax/flutter_libwownero that referenced this issue Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants