-
Notifications
You must be signed in to change notification settings - Fork 4
Quiet compiler warnings and errors to work with post C99 compilers #1
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
base: master
Are you sure you want to change the base?
Conversation
brouhaha
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean pre-C99 compilers? Is there a good reason to support pre-C99 compilers at this late date?
|
No. This is to compile quietly on recent compilers. I happen to have gcc
4.8.5 on my Linux box here. It complains about 'for (int i=0...' and
there's a warning on input() in lex.c (coming from lex.l) being declared
but not used.
This patch makes it compile totally quietly on a 5-year-old compiler.
…-ethan
On Wed, Oct 21, 2020 at 12:04 AM Eric Smith ***@***.***> wrote:
***@***.**** commented on this pull request.
Do you mean pre-C99 compilers? Is there a good reason to support pre-C99
compilers at this late date?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAINHYT7BRSUGGTXOMLYHFLSLZMVXANCNFSM4SYUVCWA>
.
|
|
That's what I mean. You're telling me that your gcc 4.8.5, which is an
quite old version of gcc, is not C99 compliant, since loop variable
declaration in the loop is legal in C99 and newer. Maybe gcc 4.8.5 is C99
compliant if you give a command line switch, --std=c99 or some such?
I don't have any issue with adding the input thing, but I'm reluctant to
move the loop variable declarations.
…On Tue, Oct 20, 2020 at 10:12 PM Ethan Dicks ***@***.***> wrote:
No. This is to compile quietly on recent compilers. I happen to have gcc
4.8.5 on my Linux box here. It complains about 'for (int i=0...' and
there's a warning on input() in lex.c (coming from lex.l) being declared
but not used.
This patch makes it compile totally quietly on a 5-year-old compiler.
-ethan
|
|
Apologies for not being clearer. The existing code is C99 compatible but apparently gcc 4.8 doesn't default to that standard and would require '--std=c99' to quiet it down. I only tripped on this because that's the version of gcc you get with RHEL7 (RHEL7 is supported until August 2023). I'm reading that gcc 5.x and newer don't throw that error. RHEL8 moved to gcc 8.x. |
|
Presumably adding --std=c99 won't break later versions of gcc, so I'd rather see that added to the Makefile. |
Conflicts: main.c
Conflicts: main.c
|
Is --std=gnu99 acceptable? That results in zero warnings with gcc 4.8. |
|
I'm finished with changes. This should be ready to go, if acceptable. |
Minor changes to get a clean compile with gcc 4.8.5