rakshasa / libtorrent

libTorrent BitTorrent library
http://rtorrent.net/downloads/
GNU General Public License v2.0
894 stars 208 forks source link

feature-bind: rak/socket_address.h:517:37: error: expected ')' before 'PRIu16' #140

Closed Chaz6 closed 7 years ago

Chaz6 commented 7 years ago

When compiling the feature-bind branch, I experience the following error during compilation:-

/bin/sh ../../../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I../../..  -I. -I./.. -I./../.. -I../../.. -I/usr/include -I/usr/include  -pthread   -g -O2 -g -DDEBUG -Wall -std=c++11 -fvisibility=hidden   -MT block.lo -MD -MP -MF .deps/block.Tpo -c -o block.lo block.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../../.. -I. -I./.. -I./../.. -I../../.. -I/usr/include -I/usr/include -pthread -g -O2 -g -DDEBUG -Wall -std=c++11 -fvisibility=hidden -MT block.lo -MD -MP -MF .deps/block.Tpo -c block.cc  -fPIC -DPIC -o .libs/block.o
In file included from ./../../net/address_list.h:42:0,
                 from ./../../protocol/extensions.h:48,
                 from ./../../protocol/peer_connection_base.h:47,
                 from block.cc:44:
../../../rak/socket_address.h: In member function 'std::string rak::socket_address_inet6::pretty_address_str() const':
../../../rak/socket_address.h:517:37: error: expected ')' before 'PRIu16'
     if (snprintf(last_char, 7, ":%" PRIu16, port()) == -1)
                                     ^
../../../rak/socket_address.h:517:51: warning: spurious trailing '%' in format [-Wformat=]
     if (snprintf(last_char, 7, ":%" PRIu16, port()) == -1)
                                                   ^
../../../rak/socket_address.h:517:51: warning: too many arguments for format [-Wformat-extra-args]
../../../rak/socket_address.h:517:51: warning: spurious trailing '%' in format [-Wformat=]
../../../rak/socket_address.h:517:51: warning: too many arguments for format [-Wformat-extra-args]

The build host is Linux 3.10.0-514.2.2.el7.x86_64 (CentOS Linux release 7.3.1611).

rakshasa commented 7 years ago

Try now.

Chaz6 commented 7 years ago

I updated to commit 39402ecdbaac5909c939b00dfe56dd5102765870 but it still fails to compile:-

/bin/sh ../../../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I../../..  -I. -I./.. -I./../.. -I../../.. -I/usr/include -I/usr/include  -pthread   -g -O2 -g -DDEBUG -Wall -std=c++11 -fvisibility=hidden   -MT block.lo -MD -MP -MF .deps/block.Tpo -c -o block.lo block.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../../.. -I. -I./.. -I./../.. -I../../.. -I/usr/include -I/usr/include -pthread -g -O2 -g -DDEBUG -Wall -std=c++11 -fvisibility=hidden -MT block.lo -MD -MP -MF .deps/block.Tpo -c block.cc  -fPIC -DPIC -o .libs/block.o
In file included from ./../../net/address_list.h:42:0,
                 from ./../../protocol/extensions.h:48,
                 from ./../../protocol/peer_connection_base.h:47,
                 from block.cc:44:
../../../rak/socket_address.h: In member function 'std::string rak::socket_address_inet6::pretty_address_str() const':
../../../rak/socket_address.h:518:37: error: expected ')' before 'PRIu16'
     if (snprintf(last_char, 7, ":%" PRIu16, port()) == -1)
                                     ^
../../../rak/socket_address.h:518:51: warning: spurious trailing '%' in format [-Wformat=]
     if (snprintf(last_char, 7, ":%" PRIu16, port()) == -1)
                                                   ^
../../../rak/socket_address.h:518:51: warning: too many arguments for format [-Wformat-extra-args]
../../../rak/socket_address.h:518:51: warning: spurious trailing '%' in format [-Wformat=]
../../../rak/socket_address.h:518:51: warning: too many arguments for format [-Wformat-extra-args]
make[4]: *** [block.lo] Error 1
rakshasa commented 7 years ago

Once more.

dwfreed commented 7 years ago

Still fails: https://travis-ci.org/rakshasa/libtorrent/jobs/184610769#L506

This StackOverflow answer may help: http://stackoverflow.com/a/30851225

Given that you're already deep in headers, probably the easiest way to accomplish that would be to define it on the command line.

rakshasa commented 7 years ago

Well, by the C++ standard should not require __STDC_FORMAT_MACROS to be defined so this is a case of not following the standards.

I guess the correct solution is to replace all uses of with <.cinttypes.> and add an autoconf check. Since I'm busy with the feature-bind branch it's going on my todo list, unless someone is willing to make a pull request.

SoapGentoo commented 7 years ago

I fixed the problem properly in https://github.com/rakshasa/libtorrent/pull/142 Why would you want to check for cinttypes in Autoconf? If a C++ compiler doesn't bring its own cinttypes header to the table, you probably have much bigger problems.