Commit graph

8 commits

Author SHA1 Message Date
Andrew Clayton
8f0dd9478e Fixed main() prototypes in auto tests.
Future releases of GCC are planning to remove[0] default support for
some old features that were removed from C99 but GCC still accepts.

We can test for these changes by using the following -Werror=
directives

  -Werror=implicit-int
  -Werror=implicit-function-declaration
  -Werror=int-conversion
  -Werror=strict-prototypes
  -Werror=old-style-definition

Doing so revealed an issue with the auto/ tests in that the test
programs always define main as

  int main()

rather than

  int main(void)

which results in a bunch of errors like

build/autotest.c:3:23: error: function declaration isn't a prototype [-Werror=strict-prototypes]
    3 |                   int main() {
      |                       ^~~~
build/autotest.c: In function 'main':
build/autotest.c:3:23: error: old-style function definition [-Werror=old-style-definition]

The fix was easy, it only required fixing the main prototype with

  find -type f -exec sed -i 's/int main() {/int main(void) {/g' {} \;

Regardless of these upcoming GCC changes, this is probably a good thing
to do anyway for correctness.

[0]: https://fedoraproject.org/wiki/Changes/PortingToModernC

Link: <https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/CJXKTLXJUPZ4F2C2VQOTNMEA5JAUPMBD/>
Link: <https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/6SGHPHPAXKCVJ6PUZ57WVDQ5TDBVIRMF/>
Reviewed-by: Alejandro Colomar <alx@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2022-10-28 03:17:31 +01:00
Alejandro Colomar
0b79735b50 Added NXT_MAYBE_UNUSED for __attribute__((__unused__)).
When testing some configurations of compilers and OSes, I noticed
that clang(1) 13 on Debian caused a function to be compiled but
unused, and the compiler triggered a compile error.

To avoid that error, use __attribute__((__unused__)).  Let's call
our wrapper NXT_MAYBE_UNUSED, since it describes itself more
precisely than the GCC attribute name.  It's also the name that
C2x (likely C23) has given to the standard attribute, which is
[[maybe_unused]], so it's also likely to be more readable because
of that name being in ISO C.
2022-04-27 01:14:22 +02:00
Sergey Kandaurov
14bc401394 Using own popcount where the compiler builtin is not available. 2018-06-20 19:34:06 +03:00
Valentin Bartenev
07b554c2b4 Configure scripts cleanup.
Thanks to 洪志道 (Hong Zhi Dao).
2018-04-11 18:29:48 +03:00
Max Romanov
83d7ab38ac Using old-style packed attribute specification for compatibility. 2017-08-02 13:01:54 +03:00
Valentin Bartenev
9d707800b0 More accurate "packed" attribute declaration. 2017-07-18 17:13:40 +03:00
Max Romanov
b53b7b0413 Build on Solaris 11 fixed. 2017-06-26 19:58:43 +03:00
Igor Sysoev
16cbf3c076 Initial version. 2017-01-17 20:00:00 +03:00