PX4 Firmware
PX4 Autopilot Software http://px4.io
px4_macros.h File Reference

A set of useful macros for enhanced runtime and compile time error detection and warning suppression. More...

#include <assert.h>
Include dependency graph for px4_macros.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define arraySize(a)   (sizeof((a))/sizeof((a[0])))
 
#define _FILE_NAME_   __FILE__
 
#define INVALID_CASE(c)   printf("Invalid Case %d, %s:%d",(c),__BASE_FILE__,__LINE__) /* todo use PANIC */
 
#define UNUSED(var)   (void)(var)
 
#define _CAT(a, b)   a ## b
 
#define CAT(a, b)   _CAT(a, b)
 
#define FREEZE_STR(s)   #s
 
#define STRINGIFY(s)   FREEZE_STR(s)
 
#define CCASSERT(predicate)   _x_CCASSERT_LINE(predicate, __LINE__)
 
#define _x_CCASSERT_LINE(predicate, line)   typedef char CAT(constraint_violated_on_line_,line)[2*((predicate)!=0)-1] __attribute__ ((unused)) ;
 
#define DO_PRAGMA(x)   _Pragma (#x)
 
#define TODO(x)   DO_PRAGMA(message ("TODO - " #x))
 

Detailed Description

A set of useful macros for enhanced runtime and compile time error detection and warning suppression.

Define NO_BLOAT to reduce bloat from file name inclusion.

The arraySize() will compute the size of an array regardless it's type

INVALID_CASE(c) should be used is case statements to ferret out unintended behavior

UNUSED(var) will suppress compile time warnings of unused variables

CCASSERT(predicate) Will generate a compile time error it the predicate is false

Definition in file px4_macros.h.

Macro Definition Documentation

◆ _CAT

#define _CAT (   a,
 
)    a ## b

Definition at line 84 of file px4_macros.h.

◆ _FILE_NAME_

#define _FILE_NAME_   __FILE__

Definition at line 68 of file px4_macros.h.

◆ _x_CCASSERT_LINE

#define _x_CCASSERT_LINE (   predicate,
  line 
)    typedef char CAT(constraint_violated_on_line_,line)[2*((predicate)!=0)-1] __attribute__ ((unused)) ;

Definition at line 103 of file px4_macros.h.

◆ arraySize

#define arraySize (   a)    (sizeof((a))/sizeof((a[0])))

Definition at line 61 of file px4_macros.h.

◆ CAT

#define CAT (   a,
 
)    _CAT(a, b)

Definition at line 86 of file px4_macros.h.

◆ CCASSERT

#define CCASSERT (   predicate)    _x_CCASSERT_LINE(predicate, __LINE__)

Definition at line 101 of file px4_macros.h.

◆ DO_PRAGMA

#define DO_PRAGMA (   x)    _Pragma (#x)

Definition at line 109 of file px4_macros.h.

◆ FREEZE_STR

#define FREEZE_STR (   s)    #s

Definition at line 90 of file px4_macros.h.

◆ INVALID_CASE

#define INVALID_CASE (   c)    printf("Invalid Case %d, %s:%d",(c),__BASE_FILE__,__LINE__) /* todo use PANIC */

Definition at line 75 of file px4_macros.h.

◆ STRINGIFY

#define STRINGIFY (   s)    FREEZE_STR(s)

Definition at line 94 of file px4_macros.h.

Referenced by MavlinkReceiver::handle_message_statustext(), and px4_build_uri().

◆ TODO

#define TODO (   x)    DO_PRAGMA(message ("TODO - " #x))

Definition at line 113 of file px4_macros.h.

◆ UNUSED

#define UNUSED (   var)    (void)(var)

Definition at line 79 of file px4_macros.h.