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

Add 'AC_PROG_CC_STDC' in configure.ac to solve compile error. #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tmogi001
Copy link

@tmogi001 tmogi001 commented Feb 8, 2018

I tried to compile this library on CentOS 7.4, but the following error occuerred.

unix-java.c:257:4: error: 'for' loop initial declarations are only allowed in C99 mode
    for (int i = 0, j = 0, s = 0; i <= els; i++, j++) {
    ^
unix-java.c:257:4: note: use option -std=c99 or -std=gnu99 to compile your code

This error is caused by the difference of C Langage Standard in gcc version.
Use AC_PROG_CC_STDC macro to avoid these error.

Macro: AC_PROG_CC_STDC

If the C compiler cannot compile ISO Standard C (currently C99), try to add an option to output variable CC to make it work. If the compiler does not support C99, fall back to supporting ANSI C89 (ISO C90).

https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/C-Compiler.html

I added this macro to configure.ac and successfully compiled with CentOS 7.4(gcc 4.8.5) and Fedora 27(gcc 7.2.1).

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

Successfully merging this pull request may close these issues.

1 participant