Keil Logo

CMSIS: C++ definitions from stdint.h do not work

Information in this knowledgebase article applies to:

  • CMSIS-Core Version 4.10 or before


Using register definition files that contain CMSIS-Core in combination with the standard header file stdint.h fails when using C++.


In the core_cmx.h header file stdint.h is included in an extern "C" { } section (see below). This was incorrect.

#ifdef __cplusplus
extern "C" {
#include <stdint.h>           /* standard types definitions        */
#include <core_cminstr.h>     /* Core Instruction Access           */
#include <core_cmfunc.h>      /* Core Function Access              */
#include <core_cmsimd.h>      /* Compiler specific SIMD Intrinsics */

#ifdef __cplusplus

Note that there is no issue in C source files.


As work-around include the standard header file stdint.h in C++ source code before the register definition file (device.h). stdint.h is protected for multiple including with:

#ifndef _STDINT_H_
#define _STDINT_H_

If the file stdint.h is included at the beginning of your C++ source code it has the C++ symbol definitions.


The problem exists with all register definition header files thatinclude the file core_cpu.h from CMSIS-Core Version 4.10 or before. The file defines the core peripherals and provides helper functions that access the core registers. The file is available for all supported processors in the following variants:

  • core_cm0.h: for the Cortex-M0 processor
  • core_cm0plus.h: for the Cortex-M0+ processor
  • core_cm3.h: for the Cortex-M3 processor
  • core_cm4.h: for the Cortex-M4 processor
  • core_cm7.h: for the Cortex-M7 processor
  • core_sc000.h: for the SecurCore SC000 processor
  • core_sc300.h: for the SecurCore SC300 processor

This issue was fixed in CMSIS-Core version 4.4.0 which is part of MDK 5.17. Download it from Keil Product Downloads page, under the Maintenance Status and Previous Versions section.



Last Reviewed: Wednesday, March 27, 2019

Did this article provide the answer you needed?
Not Sure
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.