*: 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,16 +5,16 @@
#ifndef SPA_CPU_H
#define SPA_CPU_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#include <errno.h>
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SPA_API_CPU
#ifdef SPA_API_IMPL
#define SPA_API_CPU SPA_API_IMPL

View file

@ -5,12 +5,12 @@
#ifndef SPA_DBUS_H
#define SPA_DBUS_H
#include <spa/support/loop.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/support/loop.h>
#ifndef SPA_API_DBUS
#ifdef SPA_API_IMPL
#define SPA_API_DBUS SPA_API_IMPL

View file

@ -5,13 +5,13 @@
#ifndef SPA_I18N_H
#define SPA_I18N_H
#include <spa/utils/hook.h>
#include <spa/utils/defs.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/hook.h>
#include <spa/utils/defs.h>
#ifndef SPA_API_I18N
#ifdef SPA_API_IMPL
#define SPA_API_I18N SPA_API_IMPL

View file

@ -5,15 +5,15 @@
#ifndef SPA_LOG_IMPL_H
#define SPA_LOG_IMPL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <spa/utils/type.h>
#include <spa/support/log.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* \addtogroup spa_log
* \{

View file

@ -5,16 +5,16 @@
#ifndef SPA_LOG_H
#define SPA_LOG_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#include <spa/utils/type.h>
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SPA_API_LOG
#ifdef SPA_API_IMPL
#define SPA_API_LOG SPA_API_IMPL

View file

@ -5,16 +5,16 @@
#ifndef SPA_LOOP_H
#define SPA_LOOP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <errno.h>
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <spa/support/system.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SPA_API_LOOP
#ifdef SPA_API_IMPL
#define SPA_API_LOOP SPA_API_IMPL

View file

@ -5,13 +5,13 @@
#ifndef SPA_PLUGIN_LOADER_H
#define SPA_PLUGIN_LOADER_H
#include <spa/utils/hook.h>
#include <spa/utils/dict.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/hook.h>
#include <spa/utils/dict.h>
#ifndef SPA_API_PLUGIN_LOADER
#ifdef SPA_API_IMPL
#define SPA_API_PLUGIN_LOADER SPA_API_IMPL

View file

@ -5,16 +5,16 @@
#ifndef SPA_PLUGIN_H
#define SPA_PLUGIN_H
#ifdef __cplusplus
extern "C" {
#endif
#include <errno.h>
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <spa/utils/dict.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SPA_API_PLUGIN
#ifdef SPA_API_IMPL
#define SPA_API_PLUGIN SPA_API_IMPL

View file

@ -5,12 +5,6 @@
#ifndef SPA_SYSTEM_H
#define SPA_SYSTEM_H
#ifdef __cplusplus
extern "C" {
#endif
struct itimerspec;
#include <time.h>
#include <errno.h>
#include <sys/types.h>
@ -18,6 +12,12 @@ struct itimerspec;
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#ifdef __cplusplus
extern "C" {
#endif
struct itimerspec;
#ifndef SPA_API_SYSTEM
#ifdef SPA_API_IMPL
#define SPA_API_SYSTEM SPA_API_IMPL

View file

@ -5,10 +5,6 @@
#ifndef SPA_THREAD_H
#define SPA_THREAD_H
#ifdef __cplusplus
extern "C" {
#endif
#include <string.h>
#include <errno.h>
@ -16,6 +12,10 @@ extern "C" {
#include <spa/utils/hook.h>
#include <spa/utils/dict.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SPA_API_THREAD
#ifdef SPA_API_IMPL
#define SPA_API_THREAD SPA_API_IMPL