MISRA-C:2004
Guidelines
for the use
of the
C language
in critical
systems
October 2004
Licensed to: Tyler Doering.
10 Sep 2008. Copy 1 of 1
First published October 2004
by MIRA Limited
Watling Street
Nuneaton
Warwickshire CV10 0TU
UK
www.misra-c.com
Edition 2 reprinted July 2008 incorporating Technical Corrigendum 1
© MIRA Limited, 2004, 2008.
“MISRA”, “MISRA C” and the triangle logo are registered trademarks of MIRA Limited, held on
behalf of the MISRA Consortium.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system or
transmitted in any form or by any means, electronic, mechanical or photocopying, recording or
otherwise without the prior written permission of the Publisher.
ISBN 978-0-9524156-2-6 paperback
ISBN 978-0-9524156-4-0 PDF
Printed by Hobbs the Printers Ltd
British Library Cataloguing in Publication Data.
A catalogue record for this book is available from the British Library
This copy of MISRA-C:2004 - Guidelines for the use of the C language in critical systems is
issued to Tyler Doering.
The file must not be altered in any way. No permission is given for distribution of this file. This
includes but is not exclusively limited to making the copy available to others by email, placing it
on a server for access by intra- or inter-net, or by printing and distributing hardcopies. Any such
use constitutes an infringement of copyright.
MISRA gives no guarantees about the accuracy of the information contained in this PDF version of
the Guidelines. The published paper document should be taken as authoritative.
Information is available from the MISRA web site on how to purchase printed copies of the
document.
Licensed to: Tyler Doering.
10 Sep 2008. Copy 1 of 1
i
MISRA-C:2004
Guidelines
for the use
of the
C language
in critical
systems
October 2004
Licensed to: Tyler Doering.
10 Sep 2008. Copy 1 of 1
ii
MISRA Mission Statement: To provide assistance to the automotive industry in the application
and creation within vehicle systems of safe and reliable software.
MISRA, The Motor Industry Software Reliability Association, is a collaboration between vehicle
manufacturers, component suppliers and engineering consultancies which seeks to promote best
practice in developing safety-related electronic systems in road vehicles and other embedded
systems. To this end MISRA publishes documents that provide accessible information for engineers
and management, and holds events to permit the exchange of experiences between practitioners.
www.misra.org.uk
Disclaimer
Adherence to the requirements of this document does not in itself ensure error-free robust
software or guarantee portability and re-use.
Compliance with the requirements of this document, or any other standard, does not of itself
confer immunity from legal obligations.
Licensed to: Tyler Doering.
10 Sep 2008. Copy 1 of 1
iii
In preparing the original MISRA-C:1998 [1] document, it was hoped to make some impact in the
use of software within the UK automotive industry. Since 1998, the successes and global use of
MISRA-C1 across automotive, aerospace, medical and other industries has been staggering.
Since the publication of MISRA-C:1998, we have received considerable comment of the good,
bad, and in some cases impractical rules included. We therefore set about the task of producing
an update, MISRA-C:2004 (this document), which improves on, and corrects the issues faced by
software engineers implementing MISRA-C:1998.
While producing MISRA-C:2004, the question of addressing the 1999 C standard [8] arose. At
this time, only issues with MISRA-C:1998 are addressed due to the limited support for C99 on
embedded microprocessors.
For the last few years, a dedicated group have met, representing a broad range of interests to rene
and produce MISRA-C:2004. I would like to thank this team for their effort and support.
I would also like to recognise our global partners who have aided our global preparation of
MISRA-C:2004. In the USA, this has been with the SAE J2632 committee led by Bruce Emaus.
In Japan, we have worked with representatives of JSAE, JAMA, and the MISRA Study Group,
and I would particularly like to thank Takao Futagami for his role in co-ordinating access to these
groups.
I would also like to thank all those in a wider group who have provided comments and support to
the MISRA-C effort. This includes all those who participated in the review during 2003, which
led to some rules being re-designed to address the comments received.
In presenting MISRA-C:2004, we have attempted to rene the document in a number of ways.
We have replaced general blanket rules with specic targeted rules.•
We have replaced “as appropriate” rules with denitive do / do not rules.•
We have introduced rules for arithmetic operations which provide a sound base for simple •
and robust statements.
We have 122 mandatory and 20 advisory rules.•
We have removed 15 rules which did not make sense.•
We have split complex rules into component parts.•
We have attempted to remain compatible with MISRA-C:1998, to prevent MISRA-C:1998 •
code needing to be modied to conform to MISRA-C:2004.
The MISRA-C project remains on-going, and this document has now been supplemented with
an Exemplar Test Case Suite available at at www.misra-c.com/forum to provide examples of
compliant and non-compliant code.
This document species a subset of the C programming language which is intended to be suitable
for embedded systems. It contains a list of rules concerning the use of the C programming language
together with justications and examples.
Gavin McCall BSc (Hons), MSc, C.Eng, MIEE
MISRA-C Team Leader
Foreword
Licensed to: Tyler Doering.
10 Sep 2008. Copy 1 of 1