*: 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,18 +5,18 @@
#ifndef ACP_H
#define ACP_H
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#endif
#include <stdio.h>
#include <stdarg.h>
#include <stdint.h>
#include <poll.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#endif
#ifdef __GNUC__
#define ACP_PRINTF_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1)))
#else

View file

@ -5,13 +5,13 @@
#ifndef PA_ARRAY_H
#define PA_ARRAY_H
#include <errno.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <errno.h>
#include <string.h>
typedef struct pa_array {
void *data; /**< pointer to array data */
size_t size; /**< length of array in bytes */

View file

@ -22,14 +22,14 @@
#ifndef PULSE_CARD_H
#define PULSE_CARD_H
#include "compat.h"
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#endif
#include "compat.h"
typedef struct pa_card pa_card;
struct pa_card {

View file

@ -21,12 +21,12 @@
#ifndef PULSE_CHANNELMAP_H
#define PULSE_CHANNELMAP_H
#include "spa/utils/defs.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "spa/utils/defs.h"
#define PA_CHANNELS_MAX 64
#define PA_CHANNEL_MAP_SNPRINT_MAX (PA_CHANNELS_MAX * 32)

View file

@ -22,12 +22,6 @@
#ifndef PULSE_COMPAT_H
#define PULSE_COMPAT_H
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#endif
#include <stdio.h>
#include <stdarg.h>
#include <stdint.h>
@ -39,6 +33,12 @@ extern "C" {
#include <spa/utils/string.h>
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#endif
typedef struct pa_core pa_core;
typedef void *(*pa_copy_func_t)(const void *p);

View file

@ -22,14 +22,14 @@
#ifndef PULSE_DEVICE_PORT_H
#define PULSE_DEVICE_PORT_H
#include "compat.h"
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#endif
#include "compat.h"
typedef struct pa_card pa_card;
typedef struct pa_device_port pa_device_port;

View file

@ -5,12 +5,12 @@
#ifndef PA_DYNARRAY_H
#define PA_DYNARRAY_H
#include "compat.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "array.h"
typedef struct pa_dynarray_item {
void *ptr;
} pa_dynarray_item;

View file

@ -5,12 +5,12 @@
#ifndef PA_HASHMAP_H
#define PA_HASHMAP_H
#include "array.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "array.h"
typedef unsigned (*pa_hash_func_t)(const void *p);
typedef int (*pa_compare_func_t)(const void *a, const void *b);

View file

@ -5,12 +5,12 @@
#ifndef PA_IDXSET_H
#define PA_IDXSET_H
#include "array.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "array.h"
#define PA_IDXSET_INVALID ((uint32_t) -1)
typedef unsigned (*pa_hash_func_t)(const void *p);

View file

@ -5,15 +5,15 @@
#ifndef PA_PROPLIST_H
#define PA_PROPLIST_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include "array.h"
#include "acp.h"
#ifdef __cplusplus
extern "C" {
#endif
#define PA_PROP_DEVICE_DESCRIPTION "device.description"
#define PA_PROP_DEVICE_CLASS "device.class"

View file

@ -21,12 +21,12 @@
#ifndef PA_VOLUME_H
#define PA_VOLUME_H
#include <math.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <math.h>
typedef uint32_t pa_volume_t;
#define PA_VOLUME_MUTED ((pa_volume_t) 0U)

View file

@ -5,10 +5,6 @@
#ifndef SPA_ALSA_UTILS_H
#define SPA_ALSA_UTILS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#include <math.h>
@ -35,6 +31,9 @@ extern "C" {
#include "alsa.h"
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_RATES 16

View file

@ -5,10 +5,6 @@
#ifndef SPA_ALSA_SEQ_H
#define SPA_ALSA_SEQ_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#include <math.h>
@ -33,6 +29,9 @@ extern "C" {
#include "alsa.h"
#ifdef __cplusplus
extern "C" {
#endif
struct props {
char device[64];