*: don't include standard C headers inside of extern "C"

Including C headers inside of `extern "C"` breaks use from C++. Hoist
the includes of standard C headers above the block so we don't try
to mangle the stdlib.

I initially tried to scope this with a targeted change but it's too
hard to do correctly that way. This way, we avoid whack-a-mole.

Firefox is working around this in their e21461b7b8b39cc31ba53c47d4f6f310c673ff2f
commit.

Bug: https://bugzilla.mozilla.org/1953080
This commit is contained in:
Sam James 2025-05-27 09:06:08 +01:00
parent e2731914ad
commit b943c31fd8
No known key found for this signature in database
GPG key ID: 738409F520DF9190
207 changed files with 753 additions and 752 deletions

View file

@ -5,6 +5,11 @@
#ifndef SPA_DEBUG_BUFFER_H
#define SPA_DEBUG_BUFFER_H
#include <spa/debug/context.h>
#include <spa/debug/mem.h>
#include <spa/debug/types.h>
#include <spa/buffer/type-info.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -18,11 +23,6 @@ extern "C" {
* \{
*/
#include <spa/debug/context.h>
#include <spa/debug/mem.h>
#include <spa/debug/types.h>
#include <spa/buffer/type-info.h>
#ifndef SPA_API_DEBUG_BUFFER
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_BUFFER SPA_API_IMPL

View file

@ -5,15 +5,16 @@
#ifndef SPA_DEBUG_CONTEXT_H
#define SPA_DEBUG_CONTEXT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdarg.h>
#include <ctype.h>
#include <spa/utils/defs.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* \addtogroup spa_debug
* \{

View file

@ -5,6 +5,9 @@
#ifndef SPA_DEBUG_DICT_H
#define SPA_DEBUG_DICT_H
#include <spa/debug/context.h>
#include <spa/utils/dict.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -14,9 +17,6 @@ extern "C" {
* \{
*/
#include <spa/debug/context.h>
#include <spa/utils/dict.h>
#ifndef SPA_API_DEBUG_DICT
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_DICT SPA_API_IMPL

View file

@ -5,10 +5,6 @@
#ifndef SPA_DEBUG_FILE_H
#define SPA_DEBUG_FILE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdarg.h>
#include <ctype.h>
@ -21,6 +17,10 @@ extern "C" {
#include <spa/debug/mem.h>
#include <spa/debug/pod.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* \addtogroup spa_debug
* \{

View file

@ -5,6 +5,13 @@
#ifndef SPA_DEBUG_FORMAT_H
#define SPA_DEBUG_FORMAT_H
#include <spa/pod/parser.h>
#include <spa/utils/string.h>
#include <spa/debug/context.h>
#include <spa/debug/types.h>
#include <spa/param/type-info.h>
#include <spa/param/format-utils.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -14,13 +21,6 @@ extern "C" {
* \{
*/
#include <spa/pod/parser.h>
#include <spa/utils/string.h>
#include <spa/debug/context.h>
#include <spa/debug/types.h>
#include <spa/param/type-info.h>
#include <spa/param/format-utils.h>
#ifndef SPA_API_DEBUG_FORMAT
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_FORMAT SPA_API_IMPL

View file

@ -5,10 +5,6 @@
#ifndef SPA_DEBUG_LOG_H
#define SPA_DEBUG_LOG_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdarg.h>
@ -20,6 +16,10 @@ extern "C" {
#include <spa/debug/mem.h>
#include <spa/debug/pod.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SPA_API_DEBUG_LOG
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_LOG SPA_API_IMPL

View file

@ -5,19 +5,19 @@
#ifndef SPA_DEBUG_MEM_H
#define SPA_DEBUG_MEM_H
#include <inttypes.h>
#include <spa/debug/context.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <inttypes.h>
/**
* \addtogroup spa_debug
* \{
*/
#include <spa/debug/context.h>
#ifndef SPA_API_DEBUG_MEM
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_MEM SPA_API_IMPL

View file

@ -5,6 +5,10 @@
#ifndef SPA_DEBUG_NODE_H
#define SPA_DEBUG_NODE_H
#include <spa/node/node.h>
#include <spa/debug/context.h>
#include <spa/debug/dict.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -14,10 +18,6 @@ extern "C" {
* \{
*/
#include <spa/node/node.h>
#include <spa/debug/context.h>
#include <spa/debug/dict.h>
#ifndef SPA_API_DEBUG_NODE
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_NODE SPA_API_IMPL

View file

@ -5,6 +5,12 @@
#ifndef SPA_DEBUG_POD_H
#define SPA_DEBUG_POD_H
#include <spa/debug/context.h>
#include <spa/debug/mem.h>
#include <spa/debug/types.h>
#include <spa/pod/pod.h>
#include <spa/pod/iter.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -14,12 +20,6 @@ extern "C" {
* \{
*/
#include <spa/debug/context.h>
#include <spa/debug/mem.h>
#include <spa/debug/types.h>
#include <spa/pod/pod.h>
#include <spa/pod/iter.h>
#ifndef SPA_API_DEBUG_POD
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_POD SPA_API_IMPL

View file

@ -5,6 +5,10 @@
#ifndef SPA_DEBUG_TYPES_H
#define SPA_DEBUG_TYPES_H
#include <spa/utils/type-info.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -14,10 +18,6 @@ extern "C" {
* \{
*/
#include <spa/utils/type-info.h>
#include <string.h>
#ifndef SPA_API_DEBUG_TYPES
#ifdef SPA_API_IMPL
#define SPA_API_DEBUG_TYPES SPA_API_IMPL