Skip to content

Conversation

@atsampson
Copy link

@atsampson atsampson commented Jul 11, 2025

dis6502 doesn't build with GCC 15, which defaults to the C23 language standard.

This fixes various errors and warnings reported by current versions of GCC and Clang.

Fixes #2.

Probably subsumes #1 - I haven't tested with GCC 4 which is now very old, but it does build cleanly with GCC 6 as C99.

It's declared in lex.l, so it should just be extern in the header.

GCC 10 and later default to -fno-common, so this avoids a compile error
with all recent versions.
This avoids build errors with GCC 15, which defaults to C23 where ()
means the same as (void).
Returning void * means you never need to cast the result.

This also removes a pre-ANSI function definition, which isn't valid in
C23 (and produces warnings with GCC 15).
There were a few calls to malloc that didn't check whether it returned
NULL. Use emalloc in these cases, since that does the check anyway.
We can just include the string in the following sprintf.
GCC 15 warns that the buffer might not be long enough, which is correct
(if unlikely) as %ld on its own might be 20 characters on a 64-bit
system.
It was set to a value in the switch statement later, but clang's
analyzer can't prove that one of the cases must execute, so it warns
that it may still be used uninitialized. Just set it to 0 when it's
declared.
clang's analyzer correctly warns that none of the file-reading functions
closed the file once they were done.
The input function isn't used in lex.l, so this avoids an unused
function warning.
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.

make problems

1 participant