AeroCoder
Open the tools

DO-178C HANDBOOK · CONTENTS

DO-178C HANDBOOK

/

Development

Coding

Safe language subsets, coding standards, source code reviews and the Table A-5 objectives.

Desk summary

  • 01The coding process (§5.3) turns the design into source code that implements the LLRs and architecture — and nothing else — traces to the LLRs and follows the coding standard.
  • 02Airborne code is written in a restricted subset of a language: MISRA C for C, SPARK or a profiled Ada subset for Ada, guideline sets such as MISRA C++ for C++. The subset is chosen in planning and written into the coding standard (§11.8).
  • 03Source code is verified by review and analysis against Table A-5 objectives 1–6; objective 6 hides a long list of analyses (stack, timing, overflow, floating point, uninitialised data and more).
  • 04The compiler is normally not qualified; confidence in its output comes from testing the executable object code and, at Level A, additional analysis where object code is not directly traceable to source.
  • 05Table A-5 objectives 8 and 9, new in DO-178C, cover Parameter Data Item Files.

Intuition

Coding should be the least creative step

DO-178C deliberately puts the engineering thinking into requirements and design. If the design is complete, coding is translation: careful, skilled translation, but not invention. When coders find themselves deciding what a function should do in an odd case, that is a design gap, and the right response is a problem report against the LLRs, not a clever line of code.

What the coding process must deliver

The coding objective in Table A-2 (objective 6) is that source code is developed. §5.3 adds the expectations: the code implements the LLRs and conforms to the architecture, it conforms to the Software Code Standards, it is traceable to the LLRs, and inadequacies found in requirements or design are fed back. The outputs are the Source Code (§11.11) and trace data (§11.21). Build and load instructions are written alongside the code but are verified as part of integration — see Integration & Executable Object Code.

Pitfall

Code that implements more than the design

Debug hooks left enabled, a “just in case” branch, a helper that handles a mode the requirements never mention — each is code without a requirement. It shows up as a trace gap in review (Table A-5 objective 5) or as uncovered code in structural coverage analysis, and then has to be removed, justified as deactivated code, or backed by new requirements. See Dead, Extraneous & Deactivated Code.

Languages and safe subsets

DO-178C does not prescribe a language. §4.4.2 asks that the language and compiler be chosen with their verification implications in mind and that the coding standard restrict the language to a subset whose behaviour is well defined and analysable. Every general-purpose language has constructs with undefined, unspecified or implementation-defined behaviour; the subset removes or controls them.

Common language choices for airborne software

LanguageTypical subset or guidelineStrengthsWatch-outs
CMISRA C:2012 (with amendments) or MISRA C:2023; project rules on topUniversal compiler and tool support; maps closely to hardware; the usual target of code generatorsWeak typing, implicit conversions, undefined behaviour, pointer errors. Discipline depends heavily on the subset and static analysis.
AdaSPARK subset; Ravenscar profile for tasking; profiles from ISO/IEC TR 15942Strong typing, range types, run-time checks, packages. SPARK adds proof of absence of run-time errors and of contractsSmaller talent pool and tool market; run-time checks and exceptions need a strategy in the design.
C++MISRA C++:2023 (successor to MISRA C++:2008 and AUTOSAR C++14); JSF AV C++ on some military programmesAbstraction and type safety when restrictedObject-oriented features bring the concerns addressed by DO-332: dynamic dispatch, inheritance, templates, exceptions, dynamic memory. See Object-Oriented Technology.
AssemblyRestricted to start-up, interrupt entry, context switching and hardware accessNecessary where the high-level language cannot reachHard to review, no typing, not portable. Encapsulate and keep small.

MISRA C categories

Each guideline is mandatory (no deviation permitted), required (deviation only through a formal, recorded deviation) or advisory (should be followed; departures still noted). A project may raise the category of a guideline but not lower a mandatory one.

Directives and rules

MISRA C:2012 splits guidance into directives (process or design expectations that need judgement, such as documenting implementation-defined behaviour) and rules (precise source-level constraints, many of which static analysers can check).

Decidable vs undecidable

A decidable rule can always be checked by a tool; an undecidable one (for example, whether a pointer ever goes out of bounds) can only be approximated, so review or sound analysis is needed.

Deviation

A documented, justified and approved permission to break a required rule in a specific place. Deviations are reviewed evidence, not silent suppressions.

SPARK

A formally defined Ada subset with contracts, analysed by proof tools. It can demonstrate absence of run-time errors and functional properties, which under DO-333 may replace some testing or review credit. See Formal Methods.

c

/* Before: compiles cleanly, but has three latent defects */
int16_t scale_pitch(int16_t raw)
{
    return raw * 15 / 32767;          /* int overflow risk on 16-bit targets, truncation hidden */
}

/* After: explicit widths, explicit conversion, explicit saturation */
float32_t scale_pitch_deg(int16_t raw_counts)
{
    /* LLR_PIL_004: 32767 counts = +2.0 in, scaled at 15 deg/in */
    const float32_t deg_per_count = (2.0F * 15.0F) / 32767.0F;
    float32_t cmd_deg = (float32_t)raw_counts * deg_per_count;

    if (cmd_deg > PITCH_CMD_MAX_DEG) {
        cmd_deg = PITCH_CMD_MAX_DEG;
    } else if (cmd_deg < -PITCH_CMD_MAX_DEG) {
        cmd_deg = -PITCH_CMD_MAX_DEG;
    } else {
        /* within range: no action (explicit final else per coding standard) */
    }
    return cmd_deg;
}

Worked example

What the rewrite illustrates

The second version uses fixed-width types, makes the conversion to floating point explicit rather than relying on integer promotion, carries a comment tying it to its LLR, saturates to a defined limit, and ends its if … else if chain with a final else — all typical MISRA-style expectations. Note that the saturation limit must itself come from an LLR; if it does not, it is a derived requirement that the design forgot.

What the coding standard contains

§11.8 lists the contents of the Software Code Standards: the programming languages and the subset to be used, with a reference to the language definition; source presentation rules (layout, comments, headers); naming conventions; conditions and constraints on allowed constructs, including complexity limits; and constraints on the coding tools, such as compiler options. The reference helicopter project’s code standard follows exactly that structure, and for its C code adopts a selected subset of MISRA C:2012 directives and rules — for example forbidding recursion, the dynamic allocation functions of the standard library, and reads of uninitialised automatic variables.

  • —Language and subset: the language standard version (for example ISO C99), the guideline set and which rules are adopted, raised or excluded, with rationale.
  • —Presentation: layout, comment conventions (comment the why), file and function headers, trace tags to LLRs.
  • —Naming: prefixes for units, scope (global data visibly marked) and modules.
  • —Constraints: no recursion, no dynamic allocation after initialisation, no goto, limited pointer arithmetic, single point of exit if required, maximum nesting depth and cyclomatic complexity, rules for interrupts and shared data, defensive checks on external inputs.
  • —Tool constraints: compiler version and options, forbidden optimisations, warning level and the rule that warnings are analysed; code generator configuration if code is generated.

Practitioner tip

Give every rule a reason and an example

Coders apply rules they understand. A standard that explains why each rule exists and shows a compliant and non-compliant example is followed far more consistently than a bare list — and is easier to defend when the authority asks why a rule was relaxed.

Code reviews and analyses: Table A-5 objectives 1–6

Source code verification (§6.3.4) is usually a peer review against a checklist, supported by static analysis tools. Objective 6, “Source Code is accurate and consistent”, is broader than its title: §6.3.4.f lists stack usage, memory usage, fixed-point overflow and resolution, floating-point arithmetic, resource contention and limits, worst-case execution timing, exception handling, uninitialised variables, cache management, unused variables, and data corruption caused by task or interrupt conflicts. Several of these can only be answered by dedicated analyses, not by reading code.

DO-178C Table A-5

Verification of Outputs of Software Coding & Integration Processes

#ObjectiveRefABCDOutputs
1

Source Code complies with low-level requirements

6.3.4.a·Software Verification Results (11.14)
2

Source Code complies with software architecture

6.3.4.b·Software Verification Results (11.14)
3

Source Code is verifiable

6.3.4.c··Software Verification Results (11.14)
4

Source Code conforms to standards

Checked against the Software Code Standards; static analysis tools often support this.

6.3.4.d·Software Verification Results (11.14)
5

Source Code is traceable to low-level requirements

6.3.4.e·Software Verification Results (11.14)
6

Source Code is accurate and consistent

Covers stack/memory use, fixed-point overflow, resource contention, worst-case timing and similar.

6.3.4.f·Software Verification Results (11.14)
7

Output of software integration process is complete and correct

Review compile, link and load data and memory maps for errors.

6.3.5.a·Software Verification Results (11.14)
8

Parameter Data Item File is correct and complete

Conditional: only applies when Parameter Data Item Files are used. New in DO-178C.

6.6.aSoftware Verification Cases and Procedures (11.13); Software Verification Results (11.14)
9

Verification of Parameter Data Item File is achieved

Conditional: only applies when Parameter Data Item Files are used. New in DO-178C.

6.6.b·Software Verification Results (11.14)
applies with independence
applies
· not required

A:9 B:9 C:8 D:1

Source code objectives and how teams meet them

A-5 objectiveReview focusTypical support
1 — complies with LLRsDoes the code do exactly what the LLRs say, including edge cases, and nothing more?Side-by-side review using the trace data
2 — complies with architectureDo data and control flows match the architecture? Any undeclared shared data or calls?Call-graph and data-dictionary comparison; supports coupling analysis
3 — is verifiableCan it be tested? No unreachable branches, hidden state or untestable constructsReview; testability rules in the standard
4 — conforms to standardsAll coding rules followed or formally deviatedMISRA or rule checker plus review of what tools cannot decide
5 — traceable to LLRsEvery function traces to LLRs and every LLR to codeTrace tags in code, tool reports
6 — accurate and consistentOverflow, precision, uninitialised data, timing, stack, racesAbstract-interpretation analysers, stack and WCET analysis, review

Code review checklist starter

0/10

What the auditor looks for

Code review evidence that convinces

Authorities look for review records that identify the exact code version, the LLR version it was checked against, the checklist used, the reviewers and their independence where required, and the disposition of every finding. A common finding is a review that only checked standards conformance with a tool and never compared code to LLRs. Another is static analysis warnings suppressed in bulk without individual justification.

Compiler, libraries and the code you did not write

The compiler, assembler and linker transform reviewed source into the binary that flies. They are seldom qualified as tools. Instead, confidence comes from the verification of the executable object code: requirements-based tests run on the target exercise the compiler’s output. Several extra concerns follow.

  • —Choose a mature compiler and freeze it. Record the exact version and options in the environment configuration index (SECI). Review the vendor’s known-problems list against your code, and repeat when the list is updated.
  • —Fix the options. Optimisation level, floating-point model, and alignment and packing options change behaviour. The options used for formal testing must be those of the flight build. If coverage is measured on an instrumented build, justify why the results carry over.
  • —Level A object-code concern. At Level A, structural coverage analysis may be done at source level, but where the compiler generates object code not directly traceable to source statements (for example array bound checks, inlined helpers, or switch jump tables), additional verification is needed to establish correctness of that code (§6.4.4.2.b). CAST-12 discusses approaches to source-to-object code traceability.
  • —Compiler-supplied libraries and start-up code become part of the airborne software. CAST-21 expects them to meet the same objectives: requirements, design, tests and coverage, or removal of unused functions.
  • —Treat warnings as findings. The build procedure should require every compiler and linker warning to be examined, with any accepted ones listed and justified.

Parameter Data Items: Table A-5 objectives 8 and 9

DO-178C introduced Parameter Data Items: data that influence the behaviour of the executable object code without being part of it, loaded as a separate file (§11.22). Typical examples are aircraft configuration tables, gain schedules or option enables. Table A-2 objective 7 now covers producing and loading the Parameter Data Item Files along with the executable object code. Table A-5 adds two verification objectives: that the Parameter Data Item File is correct and complete, and that its verification is achieved. In practice this means verifying each file against its structure and attribute definitions and its intended values, and showing that the executable object code has been verified for the full range of values the file may contain — so that changing a parameter within its defined limits does not require re-verifying the code.

Note

More on parameter data

Parameter data items sit at the boundary of coding, integration and configuration management, and they interact with user-modifiable software and field loading. The full treatment, including DO-200B for aeronautical databases, is in Configuration, Parameter & Aeronautical Data.

Static analysis tools and qualification

Rule checkers and sound static analysers are verification tools. If their output is simply input to a human review that still covers the objective, they need no qualification. If the project takes credit for a tool to eliminate, reduce or automate a verification activity without its output being checked — for example claiming objective 4 is satisfied because the checker reported no violations — the tool must be qualified, normally at TQL-5 under DO-330 (criterion 3). State the intended credit in the PSAC early. See Tool Qualification.

Model-based development

When code is generated from models

With a code generator, the Table A-5 objectives still apply to the generated source, but they can be met in two ways. Either the generated code is reviewed and analysed like hand-written code (often with tool support that compares code to model, itself possibly qualified), or the code generator is qualified as a development tool (criterion 1, typically TQL-1 for Level A) so that some source-level verification credit can be claimed. Either way, the code standard must cover generated code: the language subset the generator emits, naming of generated identifiers, the generator configuration as a constrained tool setting, and the compiler options. The reference project’s code standard does exactly this, and runs a MISRA conformance check and a sound run-time-error analysis on each generated module. Hand-written code that the models call — device drivers, custom blocks, legacy functions — remains ordinary hand-written code. See Code Generation & Code Verification.

Self-check

A static analysis tool reports zero MISRA C violations, and the team wants to sign off Table A-5 objective 4 on that basis with no manual standards review. What is required?

Sources & further reading

  • DO-178C §4.4.2 (language and compiler considerations), §5.3 (Software Coding Process), §6.3.4, §6.4.4.2, §6.6, §11.8, §11.11, §11.22; Annex A Tables A-2 and A-5
  • Rierson, Developing Safety-Critical Software (2013), ch. 8
  • MISRA C:2012, Guidelines for the Use of the C Language in Critical Systems (and MISRA C:2023)
  • CAST-12, Guidelines for Approving Source Code to Object Code Traceability (2002)
  • CAST-21, Compiler-Supplied Libraries
  • DO-330 (tool qualification), DO-332 (object-oriented technology), DO-333 (formal methods)
  • Model-based DO-178C/DO-331 reference project (helicopter FCC): Software Code Standards and code standard conformance reports

← Previous

Software Design: Architecture & LLR

Development

Next →

Integration & Executable Object Code

Development

On this page

What the coding process must deliverLanguages and safe subsetsWhat the coding standard containsCode reviews and analyses: Table A-5 objectives 1–6Compiler, libraries and the code you did not writeParameter Data Items: Table A-5 objectives 8 and 9Static analysis tools and qualification