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

Choice of C language mode: C99 on Linux despite C99 incompatibilities #193

Open
fweimer-rh opened this issue Nov 23, 2022 · 1 comment
Open

Comments

@fweimer-rh
Copy link

fweimer-rh commented Nov 23, 2022

config/LINUX contains this:

#define CcOptions      -ansi -fPIC -fopenmp -std=c99

However, the sources contain dozens of instances were C language constructs are not part of C99. This can be seen from compiler warnings:

closure.c:11:1: error: type defaults to 'int' in declaration of 'set_EFF'
   11 | set_EFF()
      | ^~~~~~~
closure.c: In function 'set_EFF':
closure.c:39:5: error: implicit declaration of function 'reflexive_transitive_closure'
   39 |     reflexive_transitive_closure(EFF, nvars);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Future versions of GCC may turn these into errors, to match the spirit of the C99 standard. Could you build in C89 mode instead (maybe -std=gnu89, so C89 with more GNU extensions)?

Thanks,
Florian

PS: Downstream tracking bug: https://bugzilla.redhat.com/show_bug.cgi?id=2145150

@ryandesign
Copy link

Future versions of GCC may turn these into errors

Apple clang 12 and later and llvm.org clang 16 and later already do consider implicit declaration of functions to be an error. llvm.org clang does this in C99 and later modes and using C89 mode would be a successful workaround, however Apple clang also does this in C89 mode. The way to suppress the error for either compiler would be to add -Wno-error=implicit-function-declaration to CFLAGS, but suppressing the error will no longer be possible as of C20. The best idea is not to attempt to suppress the error. It was made an error for a reason. Instead, fix it by declaring functions before using them.

The latest Apple and llvm.org clangs also consider implicit int to be an error, and the best idea is to fix it by explicitly specifying function return types and argument names and types.

The downstream tracking bug for MacPorts: https://trac.macports.org/ticket/67455

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