Skip to content

Commit 6fcb77e

Browse files
author
Cruz Monrreal
authored
Merge pull request #7434 from deepikabhavnani/version_header
Separate version header file in Mbed OS
2 parents a4117f6 + 05d8c74 commit 6fcb77e

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

mbed.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#ifndef MBED_H
1717
#define MBED_H
1818

19+
#include "platform/mbed_version.h"
20+
1921
#if MBED_CONF_RTOS_PRESENT
2022
#include "rtos/rtos.h"
2123
#endif

platform/mbed_version.h

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
/** \addtogroup platform */
3+
/** @{*/
4+
/**
5+
* \defgroup platform_version Version macros
6+
* @{
7+
*/
8+
/* mbed Microcontroller Library
9+
* Copyright (c) 2018 ARM Limited
10+
*
11+
* Licensed under the Apache License, Version 2.0 (the "License");
12+
* you may not use this file except in compliance with the License.
13+
* You may obtain a copy of the License at
14+
*
15+
* http://www.apache.org/licenses/LICENSE-2.0
16+
*
17+
* Unless required by applicable law or agreed to in writing, software
18+
* distributed under the License is distributed on an "AS IS" BASIS,
19+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
* See the License for the specific language governing permissions and
21+
* limitations under the License.
22+
*/
23+
24+
#ifndef MBED_VERSION_H
25+
#define MBED_VERSION_H
26+
27+
/** MBED_MAJOR_VERSION
28+
* Mbed OS major version
29+
*
30+
* @note 99 is default value for development version (master branch)
31+
*/
32+
#define MBED_MAJOR_VERSION 99
33+
34+
/** MBED_MINOR_VERSION
35+
* Mbed OS minor version
36+
*
37+
* @note 99 is default value for development version (master branch)
38+
*/
39+
#define MBED_MINOR_VERSION 99
40+
41+
/** MBED_PATCH_VERSION
42+
* Mbed OS patch version
43+
*
44+
* @note 99 is default value for development version (master branch)
45+
*/
46+
#define MBED_PATCH_VERSION 99
47+
48+
#define MBED_ENCODE_VERSION(major, minor, patch) ((major)*10000 + (minor)*100 + (patch))
49+
50+
/** MBED_VERSION
51+
* Mbed OS 5 version (MMmmpp - M(Major); m(minor); p(patch))
52+
*
53+
* @note 999999 is default value for development version (master branch)
54+
*/
55+
#define MBED_VERSION MBED_ENCODE_VERSION(MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION)
56+
57+
/** MBED_VERSION_CHECK
58+
* Macro can be used to check minimum Mbed OS version required for feature/library. If current version
59+
* is less than required, it will assert.
60+
*
61+
* @note: Version of master branch will be 999999 as default, hence no assert/warning is provided for
62+
* master branch code
63+
*/
64+
#define MBED_VERSION_CHECK(major, minor, patch) do { \
65+
MBED_STATIC_ASSERT((MBED_VERSION >= MBED_ENCODE_VERSION((major),(minor),(patch))), "Incompatible mbed-os version detected!!"); \
66+
} while(0)
67+
68+
#endif
69+
70+
/** @}*/
71+
/** @}*/

0 commit comments

Comments
 (0)