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

Make compiles with --std=c99 work #102

Closed
skliper opened this issue Sep 30, 2019 · 3 comments
Closed

Make compiles with --std=c99 work #102

skliper opened this issue Sep 30, 2019 · 3 comments

Comments

@skliper
Copy link
Contributor

skliper commented Sep 30, 2019

OSAL has historically attempted to be strict ANSI C90, with
obvious exceptions for cases where the code needed to use a
facility that did not yet exist.

Compile with --std=c90 if you want to see these.

The default compilation we do now does not specify that the
code should be strictly conformant to any standard, so what
we get in practice is GCC's C90 with extensions.

Turning up all the warnings using
{{{
gcc -W -Wall -Wextra -pedantic
}}}
will include a large number of very useful static code
analysis checks, but will warn about the use of C99
facilities that we want to use.

What I propose to do is to run a set of trial builds
where the build script adjusts the compiler flags,
on the fly (no commits), to be:
{{{
gcc --std=c99 -O3 -g -W -Wall -Wextra -pedantic
}}}

This asks GCC to do as thorough a job as it can do to report
any of our code that deviates from INCITS ISO/IEC 9899:1999.

Our code does require use of facilities not specified in C99,
and these facilities should be enabled, where necessary, by
the use of the appropriate Option Feature Macros. I anticipate that
this will only require certain specific source files to have
an annotation (before the #include lines) that they are to
be considered to contain XOPEN or POSIX standard sources
at a specific level of those standards.

See also CFE ticket [cfs_cfe:82]

@skliper skliper self-assigned this Sep 30, 2019
@skliper
Copy link
Contributor Author

skliper commented Sep 30, 2019

Imported from trac issue 79. Created by glimes on 2015-07-16T11:07:59, last modified: 2019-08-14T14:11:46

@skliper skliper removed their assignment Sep 30, 2019
@skliper skliper added this to the 5.1.0 milestone Oct 22, 2019
@skliper skliper removed this from the 5.1.0 milestone Jan 7, 2020
@skliper
Copy link
Contributor Author

skliper commented Jan 7, 2020

This has apparently been fixed, at least with BUILDTYPE=release (does -O3) and the following strict flags: -Wall -Werror -std=c99 -D_XOPEN_SOURCE=600 -pedantic -Wstrict-prototypes -Wcast-align -Wwrite-strings

See related issues nasa/cFS#39, nasa/cFE#24

@skliper skliper closed this as completed Jan 7, 2020
@jphickey
Copy link
Contributor

jphickey commented Jan 7, 2020

Note that -Wcast-align is architecture-dependent. It still does not compile cleanly on MIPS/SPARC, but there are other issue tickets covering that aspect.

I would hold off on adding at least -Wcast-align to the default set of flags, however, due to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants