C Programming

10. February 2012

I’m planning on adding topics of interest to this as I go along…

Most avionics software is implemented in the C programming language (from my personal experience).

Here’s the C99 Standard that’s commonly followed.

C99 Standard (Final Version)

 

Compiler Preprocessor Directives

 

The following are equivalent (all check whether a macro, _A_, is defined):

#ifdef  _A_

#if defined _A_

#if defined(_A_)

 

Slightly different is (checks if _A_ is defined and non-zero):

#if _A_

 

  #ifdef _A_ #if defined _A_ #if defined(_A_) #if _A_
#define _A_ TRUE TRUE TRUE FALSE
#define _A_ 0 TRUE TRUE TRUE FALSE
#define _A_ 1 TRUE TRUE TRUE TRUE

 

Notes:

1) #ifdef and #ifndef only allow checking of a single macro

2) #elif is the else version of #if


 

 

 

  By John Dorsey  IT Brigade Inc.           

CCS, Embedded, Avionics, DO-178B