Skip to contentSkip to conversation

tools/lib/thermal: fix misplaced extern "C" closing brace

PATCH Applied Andreas Haufler 2 participants 2 messages Jul 21 – Aug 7 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/lib/thermal: fix misplaced extern "C" closing brace

The public libthermal header opens the C++ 'extern "C" {' block inside the __LIBTHERMAL_H include guard, but places the closing brace after the guard has already ended:

	#endif /* __LIBTHERMAL_H */

	#ifdef __cplusplus
	}
	#endif

On a single inclusion the braces still balance, so the problem is invisible. On the second inclusion of the header in the same C++ translation unit the include guard skips the opening 'extern "C" {', while the closing '}' lives outside the guard and is emitted anyway. This leaves a stray '}' and breaks compilation for any C++ consumer that includes the header more than once.

Move the closing block inside the include guard so both halves of the 'extern "C"' declaration are guarded consistently.

---
 tools/lib/thermal/include/thermal.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/thermal/include/thermal.h +2 -2
index 818ecdfb4..d9097271d 100644
@@ -175,8 +175,8 @@ LIBTHERMAL_API thermal_error_t thermal_sampling_handle(struct thermal_handler *t
 
 LIBTHERMAL_API int thermal_sampling_fd(struct thermal_handler *th);
 
-#endif /* __LIBTHERMAL_H */
-
 #ifdef __cplusplus
 }
 #endif
+
+#endif /* __LIBTHERMAL_H */
Signature · 1 line
2.50.1 (Apple Git-155)
#1 lore raw
Quoted 17 lines · Andreas Haufler

The public libthermal header opens the C++ 'extern "C" {' block inside the __LIBTHERMAL_H include guard, but places the closing brace after the guard has already ended:

	#endif /* __LIBTHERMAL_H */

	#ifdef __cplusplus
	}
	#endif

On a single inclusion the braces still balance, so the problem is invisible. On the second inclusion of the header in the same C++ translation unit the include guard skips the opening 'extern "C" {', while the closing '}' lives outside the guard and is emitted anyway. This leaves a stray '}' and breaks compilation for any C++ consumer that includes the header more than once.

Quoted 5 lines

Move the closing block inside the include guard so both halves of the 'extern "C"' declaration are guarded consistently.

---

Applied, thanks for the fix