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

Errors with -Werror=redundant-decls #2205

Open
ghenry opened this issue Feb 8, 2022 · 3 comments
Open

Errors with -Werror=redundant-decls #2205

ghenry opened this issue Feb 8, 2022 · 3 comments

Comments

@ghenry
Copy link

ghenry commented Feb 8, 2022

Hi all,

I've just brough Zyre into my project and am getting this build error:

https://github.com/SentryPeer/SentryPeer/runs/5101350050?check_suite_focus=true

gcc -DHAVE_CONFIG_H -I.    -Wall -Werror -Wextra -Wpedantic -pedantic -Wformat=2 -Wno-unused-parameter -Wshadow -Wwrite-strings -Wstrict-prototypes -Wold-style-definition -Wredundant-decls -Wnested-externs -Wmissing-include-dirs -std=c18 -D_FORTIFY_SOURCE=2 -fpie -fpic -g3 -O2 -fstack-protector-strong -grecord-gcc-switches -Werror=format-security -Werror=implicit-function-declaration -Wmisleading-indentation  -g -O2 -pthread -I/home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include -I/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include -I/home/linuxbrew/.linuxbrew/Cellar/zeromq/4.3.4/include -I/home/linuxbrew/.linuxbrew/Cellar/libsodium/1.0.18_1/include -I/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include -I/home/linuxbrew/.linuxbrew/Cellar/zeromq/4.3.4/include -I/home/linuxbrew/.linuxbrew/Cellar/libsodium/1.0.18_1/include -I/home/linuxbrew/.linuxbrew/Cellar/zeromq/4.3.4/include -I/home/linuxbrew/.linuxbrew/Cellar/libsodium/1.0.18_1/include -MT src/sentrypeer.o -MD -MP -MF $depbase.Tpo -c -o src/sentrypeer.o src/sentrypeer.c &&\
mv -f $depbase.Tpo $depbase.Po
In file included from /home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/czmq_library.h:159,
                 from /home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/czmq.h:37,
                 from /home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include/zyre_library.h:26,
                 from /home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include/zyre.h:23,
                 from src/conf.h:20,
                 from src/sentrypeer.c:25:
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zclock.h:67:18: error: redundant redeclaration of ‘zclock_log’ [-Werror=redundant-decls]
   67 | CZMQ_EXPORT void zclock_log (const char *format, ...) CHECK_PRINTF (1);
      |                  ^~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zclock.h:64:5: note: previous declaration of ‘zclock_log’ with type ‘void(const char *, ...)’
   64 |     zclock_log (const char *format, ...);
      |     ^~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/czmq_library.h:160,
                 from /home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/czmq.h:37,
                 from /home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include/zyre_library.h:26,
                 from /home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include/zyre.h:23,
                 from src/conf.h:20,
                 from src/sentrypeer.c:25:
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zconfig.h:194:5: error: redundant redeclaration of ‘zconfig_test’ [-Werror=redundant-decls]
  194 |     zconfig_test (bool verbose);
      |     ^~~~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zconfig.h:168:5: note: previous declaration of ‘zconfig_test’ with type ‘void(_Bool)’
  168 |     zconfig_test (bool verbose);
      |     ^~~~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zconfig.h:197:18: error: redundant redeclaration of ‘zconfig_set_value’ [-Werror=redundant-decls]
  197 | CZMQ_EXPORT void zconfig_set_value (zconfig_t *self, const char *format, ...) CHECK_PRINTF (2);
      |                  ^~~~~~~~~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zconfig.h:82:5: note: previous declaration of ‘zconfig_set_value’ with type ‘void(zconfig_t *, const char *, ...)’ {aka ‘void(struct _zconfig_t *, const char *, ...)’}
   82 |     zconfig_set_value (zconfig_t *self, const char *format, ...) CHECK_PRINTF (2);
      |     ^~~~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/czmq_library.h:172,
                 from /home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/czmq.h:37,
                 from /home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include/zyre_library.h:26,
                 from /home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include/zyre.h:23,
                 from src/conf.h:20,
                 from src/sentrypeer.c:25:
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zmsg.h:278:17: error: redundant redeclaration of ‘zmsg_addstrf’ [-Werror=redundant-decls]
  278 | CZMQ_EXPORT int zmsg_addstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2);
      |                 ^~~~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zmsg.h:131:5: note: previous declaration of ‘zmsg_addstrf’ with type ‘int(zmsg_t *, const char *, ...)’ {aka ‘int(struct _zmsg_t *, const char *, ...)’}
  131 |     zmsg_addstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2);
      |     ^~~~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zmsg.h:279:17: error: redundant redeclaration of ‘zmsg_pushstrf’ [-Werror=redundant-decls]
  279 | CZMQ_EXPORT int zmsg_pushstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2);
      |                 ^~~~~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zmsg.h:126:5: note: previous declaration of ‘zmsg_pushstrf’ with type ‘int(zmsg_t *, const char *, ...)’ {aka ‘int(struct _zmsg_t *, const char *, ...)’}
  126 |     zmsg_pushstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2);
      |     ^~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/czmq_library.h:175,
                 from /home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/czmq.h:37,
                 from /home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include/zyre_library.h:26,
                 from /home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include/zyre.h:23,
                 from src/conf.h:20,
                 from src/sentrypeer.c:25:
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zstr.h:129:17: error: redundant redeclaration of ‘zstr_sendf’ [-Werror=redundant-decls]
  129 | CZMQ_EXPORT int zstr_sendf (void *dest, const char *format, ...) CHECK_PRINTF (2);
      |                 ^~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zstr.h:61:5: note: previous declaration of ‘zstr_sendf’ with type ‘int(void *, const char *, ...)’
   61 |     zstr_sendf (void *dest, const char *format, ...) CHECK_PRINTF (2);
      |     ^~~~~~~~~~
cc1: all warnings being treated as errors
Process finished with exit code 2

I've posted here before hand:

https://lists.zeromq.org/pipermail/zeromq-dev/2022-February/033675.html

If I remove -Werror=redundant-decls, all is well. clang is fine, it's gcc. What am I doing wrong here as a user?

Thanks.

@bluca
Copy link
Member

bluca commented Feb 8, 2022

Just install libczmq-dev, no need to build it

@ghenry
Copy link
Author

ghenry commented Feb 8, 2022

Hi @bluca

If you look here, it's all installed via Homebrew and PKG_CHECK_MODULES is used to find it:

https://github.com/SentryPeer/SentryPeer/runs/5101350050?check_suite_focus=true#step:3:360

The building and installing of libzcmq is done for me. I don't think that would resolve the -Werror=redundant-decl issue?

Thanks.

@ghenry
Copy link
Author

ghenry commented Feb 8, 2022

Proved this away from my project:

all OK:

~/src/zyre/examples/minimal [master*]$ gcc -Werror=all `pkg-config --libs --cflags libzyre libczmq` minimal.c -o minimal

with -Werror=redundant-decls:

gcc -Werror=redundant-decls `pkg-config --libs --cflags libzyre ` minimal.c -o minimal
In file included from /home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/czmq_library.h:159,
                 from /home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/czmq.h:37,
                 from /home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include/zyre_library.h:26,
                 from /home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include/zyre.h:23,
                 from minimal.c:25:
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zclock.h:67:18: error: redundant redeclaration of ‘zclock_log’ [-Werror=redundant-decls]
   67 | CZMQ_EXPORT void zclock_log (const char *format, ...) CHECK_PRINTF (1);
      |                  ^~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zclock.h:64:5: note: previous declaration of ‘zclock_log’ with type ‘void(const char *, ...)’
   64 |     zclock_log (const char *format, ...);
      |     ^~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/czmq_library.h:160,
                 from /home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/czmq.h:37,
                 from /home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include/zyre_library.h:26,
                 from /home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include/zyre.h:23,
                 from minimal.c:25:
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zconfig.h:194:5: error: redundant redeclaration of ‘zconfig_test’ [-Werror=redundant-decls]
  194 |     zconfig_test (bool verbose);
      |     ^~~~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zconfig.h:168:5: note: previous declaration of ‘zconfig_test’ with type ‘void(_Bool)’
  168 |     zconfig_test (bool verbose);
      |     ^~~~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zconfig.h:197:18: error: redundant redeclaration of ‘zconfig_set_value’ [-Werror=redundant-decls]
  197 | CZMQ_EXPORT void zconfig_set_value (zconfig_t *self, const char *format, ...) CHECK_PRINTF (2);
      |                  ^~~~~~~~~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zconfig.h:82:5: note: previous declaration of ‘zconfig_set_value’ with type ‘void(zconfig_t *, const char *, ...)’ {aka ‘void(struct _zconfig_t *, const char *, ...)’}
   82 |     zconfig_set_value (zconfig_t *self, const char *format, ...) CHECK_PRINTF (2);
      |     ^~~~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/czmq_library.h:172,
                 from /home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/czmq.h:37,
                 from /home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include/zyre_library.h:26,
                 from /home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include/zyre.h:23,
                 from minimal.c:25:
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zmsg.h:278:17: error: redundant redeclaration of ‘zmsg_addstrf’ [-Werror=redundant-decls]
  278 | CZMQ_EXPORT int zmsg_addstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2);
      |                 ^~~~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zmsg.h:131:5: note: previous declaration of ‘zmsg_addstrf’ with type ‘int(zmsg_t *, const char *, ...)’ {aka ‘int(struct _zmsg_t *, const char *, ...)’}
  131 |     zmsg_addstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2);
      |     ^~~~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zmsg.h:279:17: error: redundant redeclaration of ‘zmsg_pushstrf’ [-Werror=redundant-decls]
  279 | CZMQ_EXPORT int zmsg_pushstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2);
      |                 ^~~~~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zmsg.h:126:5: note: previous declaration of ‘zmsg_pushstrf’ with type ‘int(zmsg_t *, const char *, ...)’ {aka ‘int(struct _zmsg_t *, const char *, ...)’}
  126 |     zmsg_pushstrf (zmsg_t *self, const char *format, ...) CHECK_PRINTF (2);
      |     ^~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/czmq_library.h:175,
                 from /home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/czmq.h:37,
                 from /home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include/zyre_library.h:26,
                 from /home/linuxbrew/.linuxbrew/Cellar/zyre/2.0.1/include/zyre.h:23,
                 from minimal.c:25:
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zstr.h:129:17: error: redundant redeclaration of ‘zstr_sendf’ [-Werror=redundant-decls]
  129 | CZMQ_EXPORT int zstr_sendf (void *dest, const char *format, ...) CHECK_PRINTF (2);
      |                 ^~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/czmq/4.2.1/include/zstr.h:61:5: note: previous declaration of ‘zstr_sendf’ with type ‘int(void *, const char *, ...)’
   61 |     zstr_sendf (void *dest, const char *format, ...) CHECK_PRINTF (2);
      |     ^~~~~~~~~~
cc1: some warnings being treated as errors

Could this be due to how Homebrew has built czmq I wonder? I'll check with libczmq-dev like you suggest and check out the Homebrew formula.

ghenry added a commit to SentryPeer/SentryPeer that referenced this issue Feb 9, 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

2 participants