Skip to content

Commit c315475

Browse files
pabigotioannisg
authored andcommitted
arch/common: rearrange for standard use of extern "C"
Consistently place C++ use of extern "C" after all include directives, within the negative branch of _ASMLANGUAGE if used. Background from issue #17997: Declarations that use C linkage should be placed within extern "C" so the language linkage is correct when the header is included by a C++ compiler. Similarly #include directives should be outside the extern "C" to ensure the language-specific default linkage is applied to any declarations provided by the included header. See: https://en.cppreference.com/w/cpp/language/language_linkage Signed-off-by: Peter Bigot <[email protected]>
1 parent ddf9b14 commit c315475

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

include/arch/common/ffs.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
#ifndef ZEPHYR_INCLUDE_ARCH_COMMON_FFS_H_
99
#define ZEPHYR_INCLUDE_ARCH_COMMON_FFS_H_
1010

11+
#ifndef _ASMLANGUAGE
12+
13+
#include <zephyr/types.h>
14+
1115
#ifdef __cplusplus
1216
extern "C" {
1317
#endif
1418

15-
#ifndef _ASMLANGUAGE
16-
17-
#include <zephyr/types.h>
1819
/**
1920
*
2021
* @brief find most significant bit set in a 32-bit word
@@ -54,12 +55,10 @@ static ALWAYS_INLINE unsigned int find_lsb_set(u32_t op)
5455
return __builtin_ffs(op);
5556
}
5657

57-
#endif /* _ASMLANGUAGE */
58-
59-
6058
#ifdef __cplusplus
6159
}
6260
#endif
6361

62+
#endif /* _ASMLANGUAGE */
6463

6564
#endif /* ZEPHYR_INCLUDE_ARCH_COMMON_FFS_H_ */

include/arch/common/sys_io.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212
#ifndef ZEPHYR_INCLUDE_ARCH_COMMON_SYS_IO_H_
1313
#define ZEPHYR_INCLUDE_ARCH_COMMON_SYS_IO_H_
1414

15-
#ifdef __cplusplus
16-
extern "C" {
17-
#endif
18-
1915
#ifndef _ASMLANGUAGE
2016

2117
#include <zephyr/types.h>
2218
#include <sys/sys_io.h>
2319

20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
2423

2524
static ALWAYS_INLINE u8_t sys_read8(mem_addr_t addr)
2625
{
@@ -140,10 +139,10 @@ static ALWAYS_INLINE
140139
return ret;
141140
}
142141

143-
#endif
144-
145142
#ifdef __cplusplus
146143
}
147144
#endif
148145

146+
#endif /* _ASMLANGUAGE */
147+
149148
#endif /* ZEPHYR_INCLUDE_ARCH_COMMON_SYS_IO_H_ */

0 commit comments

Comments
 (0)