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

Inconsistent prototype in elf2cfetbl.c : OutputDataToTargetFile #135

Open
dmopalmer opened this issue May 22, 2023 · 1 comment
Open

Inconsistent prototype in elf2cfetbl.c : OutputDataToTargetFile #135

dmopalmer opened this issue May 22, 2023 · 1 comment

Comments

@dmopalmer
Copy link

Describe the bug

The function OutputDataToTargetFile in elf2cfetbl.c is prototyped on line 84 with a void argument list but defined on line 2486 with an empty argument list. This causes the compilation to error out if the compiler and its flags are sufficiently strict.

...
int32 OutputDataToTargetFile(void);
...
int32 OutputDataToTargetFile()

The fix is to change the line 2486 argument list to void

To Reproduce

By inspection:

e.g. This description here

According to the C Standard, subclause 6.7.6.3, paragraph 14 [ISO/IEC 9899:2011],

An identifier list declares only the identifiers of the parameters of the function. An empty list in a function declarator that is part of a definition of that function specifies that the function has no parameters. The empty list in a function declarator that is not part of a definition of that function specifies that no information about the number or types of the parameters is supplied.
Subclause 6.11.6 states that
The use of function declarators with empty parentheses (not prototype-format parameter type declarators) is an obsolescent feature.
Consequently, functions that accept no arguments should explicitly declare a void parameter in their parameter list. This holds true in both the declaration and definition sections (which should match).

This is caught and rejected by sufficiently-strict (with flags) compilers. One example is the current Apple Mac Clang compiler

% cc --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.4.0
Thread model: posix

with flags including -std=c99 -pedantic -Wall -Wstrict-prototypes.

Admittedly, the Mac is not a cFS supported system, but clang is a pretty standard compiler, and eventually you can expect gcc to complain as well.

System observed on:

  • MacBook Pro (Intel)
  • OS: MacOS Ventura 13.3.1
  • Versions: clang version 14.0.3
@dbhinz
Copy link

dbhinz commented Feb 5, 2024

I'm seeing this problem as well.

  • MacMini (M2 Pro)
  • OS: macOS Sonoma
  • Versions: clang version 15.0.0

dmopalmer added a commit to dmopalmer/elf2cfetbl that referenced this issue Jul 2, 2024
Fixing prototype for issue nasa#135.
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