Skip to content

Commit ddf9b14

Browse files
pabigotioannisg
authored andcommitted
soc/arm/nxp*: 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. Remove extern "C" support from files that don't declare objects or functions. 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 0ddcf49 commit ddf9b14

File tree

8 files changed

+6
-62
lines changed

8 files changed

+6
-62
lines changed

soc/arm/nxp_imx/mcimx6x_m4/soc.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
#ifndef _SOC__H_
88
#define _SOC__H_
99

10-
#ifdef __cplusplus
11-
extern "C" {
12-
#endif
13-
1410
#ifndef _ASMLANGUAGE
1511

1612
#include "rdc.h"
@@ -20,8 +16,4 @@ extern "C" {
2016

2117
#endif /* !_ASMLANGUAGE */
2218

23-
#ifdef __cplusplus
24-
}
25-
#endif
26-
2719
#endif /* _SOC__H_ */

soc/arm/nxp_imx/mcimx7_m4/soc.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
#ifndef _SOC__H_
88
#define _SOC__H_
99

10-
#ifdef __cplusplus
11-
extern "C" {
12-
#endif
13-
1410
#ifndef _ASMLANGUAGE
1511

1612
#include "rdc.h"
@@ -21,8 +17,4 @@ extern "C" {
2117

2218
#endif /* !_ASMLANGUAGE */
2319

24-
#ifdef __cplusplus
25-
}
26-
#endif
27-
2820
#endif /* _SOC__H_ */

soc/arm/nxp_imx/rt/soc.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99

1010
#include <sys/util.h>
1111

12-
#ifdef __cplusplus
13-
extern "C" {
14-
#endif
15-
1612
#ifndef _ASMLANGUAGE
1713

1814
#include <fsl_common.h>
@@ -23,6 +19,10 @@ extern "C" {
2319
*/
2420
#include <kernel_includes.h>
2521

22+
#ifdef __cplusplus
23+
extern "C" {
24+
#endif
25+
2626
#if defined(CONFIG_DISK_ACCESS_USDHC1) || \
2727
defined(CONFIG_DISK_ACCESS_USDHC2)
2828

@@ -36,10 +36,10 @@ void imxrt_usdhc_pinmux_cb_register(usdhc_pin_cfg_cb cb);
3636

3737
#endif
3838

39-
#endif /* !_ASMLANGUAGE */
40-
4139
#ifdef __cplusplus
4240
}
4341
#endif
4442

43+
#endif /* !_ASMLANGUAGE */
44+
4545
#endif /* _SOC__H_ */

soc/arm/nxp_kinetis/k6x/soc.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717

1818
#include <sys/util.h>
1919

20-
#ifdef __cplusplus
21-
extern "C" {
22-
#endif
23-
2420
/* default system clock */
2521

2622
#define SYSCLK_DEFAULT_IOSC_HZ MHZ(120)
@@ -40,8 +36,4 @@ extern "C" {
4036

4137
#endif /* !_ASMLANGUAGE */
4238

43-
#ifdef __cplusplus
44-
}
45-
#endif
46-
4739
#endif /* _SOC__H_ */

soc/arm/nxp_kinetis/kl2x/soc.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99

1010
#include <sys/util.h>
1111

12-
#ifdef __cplusplus
13-
extern "C" {
14-
#endif
15-
1612
#define UART0_CLK_SRC kCLOCK_CoreSysClk
1713

1814
#ifndef _ASMLANGUAGE
@@ -24,8 +20,4 @@ extern "C" {
2420

2521
#endif /* !_ASMLANGUAGE */
2622

27-
#ifdef __cplusplus
28-
}
29-
#endif
30-
3123
#endif /* _SOC__H_ */

soc/arm/nxp_kinetis/kwx/soc.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010

1111
#include <sys/util.h>
1212

13-
#ifdef __cplusplus
14-
extern "C" {
15-
#endif
16-
1713
#if defined(CONFIG_SOC_MKW40Z4) || defined(CONFIG_SOC_MKW41Z4)
1814

1915
#define LPUART0_CLK_SRC kCLOCK_CoreSysClk
@@ -35,8 +31,4 @@ extern "C" {
3531

3632
#endif /* !_ASMLANGUAGE */
3733

38-
#ifdef __cplusplus
39-
}
40-
#endif
41-
4234
#endif /* _SOC__H_ */

soc/arm/nxp_lpc/lpc54xxx/soc.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
#ifndef _SOC__H_
1616
#define _SOC__H_
1717

18-
#ifdef __cplusplus
19-
extern "C" {
20-
#endif
21-
2218
#ifndef _ASMLANGUAGE
2319
#include <device.h>
2420
#include <sys/util.h>
@@ -36,8 +32,4 @@ extern "C" {
3632
#define IOCON_PIO_SLEW_STANDARD 0x00u
3733
#define IOCON_PIO_MODE_PULLUP 0x10u
3834

39-
#ifdef __cplusplus
40-
}
41-
#endif
42-
4335
#endif /* _SOC__H_ */

soc/arm/nxp_lpc/lpc55xxx/soc.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
#ifndef _SOC__H_
1616
#define _SOC__H_
1717

18-
#ifdef __cplusplus
19-
extern "C" {
20-
#endif
21-
2218
#ifndef _ASMLANGUAGE
2319
#include <device.h>
2420
#include <sys/util.h>
@@ -37,8 +33,4 @@ extern "C" {
3733
#define IOCON_PIO_MODE_PULLUP 0x20u /*!<@brief Selects pull-up function */
3834
#define IOCON_PIO_INPFILT_OFF 0x1000u /*!<@brief Input filter disabled */
3935

40-
#ifdef __cplusplus
41-
}
42-
#endif
43-
4436
#endif /* _SOC__H_ */

0 commit comments

Comments
 (0)