*: 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,12 +5,12 @@
#ifndef AVB_INTERNAL_H
#define AVB_INTERNAL_H
#include <pipewire/pipewire.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <pipewire/pipewire.h>
struct server;
struct avb_mrp;

View file

@ -5,16 +5,16 @@
#ifndef __PIPEWIRE_EXT_CLIENT_NODE0_H__
#define __PIPEWIRE_EXT_CLIENT_NODE0_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/param/param.h>
#include <spa/node/node.h>
#include <pipewire/proxy.h>
#ifdef __cplusplus
extern "C" {
#endif
#define PW_TYPE_INTERFACE_ClientNode PW_TYPE_INFO_INTERFACE_BASE "ClientNode"
#define PW_VERSION_CLIENT_NODE0 0

View file

@ -5,16 +5,16 @@
#ifndef __PIPEWIRE_CLIENT_NODE0_TRANSPORT_H__
#define __PIPEWIRE_CLIENT_NODE0_TRANSPORT_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <string.h>
#include <spa/utils/defs.h>
#include <pipewire/mem.h>
#ifdef __cplusplus
extern "C" {
#endif
/** information about the transport region \memberof pw_client_node */
struct pw_client_node0_transport_info {
int memfd; /**< the memfd of the transport area */

View file

@ -5,10 +5,6 @@
#ifndef PIPEWIRE_WEAK_JACK_H
#define PIPEWIRE_WEAK_JACK_H
#ifdef __cplusplus
extern "C" {
#endif
#include "config.h"
#include <dlfcn.h>
@ -17,6 +13,10 @@ extern "C" {
#include <jack/transport.h>
#include <jack/midiport.h>
#ifdef __cplusplus
extern "C" {
#endif
struct weakjack {
jack_nframes_t (*cycle_wait) (jack_client_t* client);
void (*cycle_signal) (jack_client_t* client, int status);

View file

@ -5,15 +5,15 @@
#ifndef PIPEWIRE_PROTOCOL_NATIVE_CONNECTION_H
#define PIPEWIRE_PROTOCOL_NATIVE_CONNECTION_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <pipewire/extensions/protocol-native.h>
#ifdef __cplusplus
extern "C" {
#endif
struct pw_protocol_native_connection_events {
#define PW_VERSION_PROTOCOL_NATIVE_CONNECTION_EVENTS 0
uint32_t version;

View file

@ -5,16 +5,16 @@
#ifndef PIPEWIRE_INTERFACES_V0_H
#define PIPEWIRE_INTERFACES_V0_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/param/param.h>
#include <spa/node/node.h>
#include <pipewire/pipewire.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Core */
#define PW_VERSION_CORE_V0 0

View file

@ -5,10 +5,6 @@
#ifndef PIPEWIRE_MANAGER_H
#define PIPEWIRE_MANAGER_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <spa/utils/defs.h>
@ -16,6 +12,10 @@ extern "C" {
#include <pipewire/pipewire.h>
#ifdef __cplusplus
extern "C" {
#endif
struct client;
struct pw_manager_object;

View file

@ -5,13 +5,13 @@
#ifndef PIPEWIRE_PROTOCOL_PULSE_H
#define PIPEWIRE_PROTOCOL_PULSE_H
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#define PW_PROTOCOL_PULSE_DEFAULT_PORT 4713
#define PW_PROTOCOL_PULSE_DEFAULT_SOCKET "native"

View file

@ -5,14 +5,14 @@
#ifndef PIPEWIRE_RTSP_CLIENT_H
#define PIPEWIRE_RTSP_CLIENT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#include <pipewire/pipewire.h>
#ifdef __cplusplus
extern "C" {
#endif
struct pw_rtsp_client;
struct pw_rtsp_client_events {

View file

@ -5,14 +5,14 @@
#ifndef PIPEWIRE_ARRAY_H
#define PIPEWIRE_ARRAY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <errno.h>
#include <spa/utils/defs.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef PW_API_ARRAY
#define PW_API_ARRAY static inline
#endif

View file

@ -5,10 +5,6 @@
#ifndef PIPEWIRE_CLIENT_H
#define PIPEWIRE_CLIENT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/param/param.h>
@ -16,6 +12,10 @@ extern "C" {
#include <pipewire/proxy.h>
#include <pipewire/permission.h>
#ifdef __cplusplus
extern "C" {
#endif
/** \defgroup pw_client Client
* Client interface
*/

View file

@ -5,13 +5,13 @@
#ifndef PIPEWIRE_CONTEXT_H
#define PIPEWIRE_CONTEXT_H
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
/** \defgroup pw_context Context
*
* \brief The PipeWire context object manages all locally available

View file

@ -5,12 +5,12 @@
#ifndef PIPEWIRE_CONTROL_H
#define PIPEWIRE_CONTROL_H
#include <spa/utils/hook.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/hook.h>
/** \defgroup pw_control Control
*
* \brief A control can be used to control a port property.

View file

@ -5,10 +5,6 @@
#ifndef PIPEWIRE_CORE_H
#define PIPEWIRE_CORE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#include <errno.h>
@ -16,6 +12,10 @@ extern "C" {
#include <pipewire/type.h>
#ifdef __cplusplus
extern "C" {
#endif
/** \defgroup pw_core Core
*
* \brief The core global object.

View file

@ -5,13 +5,13 @@
#ifndef PIPEWIRE_DATA_LOOP_H
#define PIPEWIRE_DATA_LOOP_H
#include <spa/utils/hook.h>
#include <spa/support/thread.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/hook.h>
#include <spa/support/thread.h>
/** \defgroup pw_data_loop Data Loop
*
* \brief PipeWire rt-loop object

View file

@ -5,15 +5,15 @@
#ifndef PIPEWIRE_DEVICE_H
#define PIPEWIRE_DEVICE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <pipewire/proxy.h>
#ifdef __cplusplus
extern "C" {
#endif
/** \defgroup pw_device Device
* Device interface
*/

View file

@ -5,13 +5,13 @@
#ifndef PIPEWIRE_EXT_CLIENT_NODE_H
#define PIPEWIRE_EXT_CLIENT_NODE_H
#include <spa/utils/defs.h>
#include <spa/param/param.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/param/param.h>
/** \defgroup pw_client_node Client Node
* Client node interface
*/

View file

@ -5,15 +5,15 @@
#ifndef PIPEWIRE_EXT_METADATA_H
#define PIPEWIRE_EXT_METADATA_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <errno.h>
#ifdef __cplusplus
extern "C" {
#endif
/** \defgroup pw_metadata Metadata
* Metadata interface
*/

View file

@ -5,12 +5,12 @@
#ifndef PIPEWIRE_EXT_PROFILER_H
#define PIPEWIRE_EXT_PROFILER_H
#include <spa/utils/defs.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
/** \defgroup pw_profiler Profiler
* Profiler interface
*/

View file

@ -5,15 +5,15 @@
#ifndef PIPEWIRE_EXT_PROTOCOL_NATIVE_H
#define PIPEWIRE_EXT_PROTOCOL_NATIVE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <pipewire/proxy.h>
#include <pipewire/resource.h>
#ifdef __cplusplus
extern "C" {
#endif
/** \defgroup pw_protocol_native Native Protocol
* PipeWire native protocol interface
*/

View file

@ -5,12 +5,12 @@
#ifndef PIPEWIRE_EXT_SECURITY_CONTEXT_H
#define PIPEWIRE_EXT_SECURITY_CONTEXT_H
#include <spa/utils/defs.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
/** \defgroup pw_security_context Security Context
* Security Context interface
*/

View file

@ -5,10 +5,6 @@
#ifndef PIPEWIRE_FACTORY_H
#define PIPEWIRE_FACTORY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#include <errno.h>
@ -17,6 +13,10 @@ extern "C" {
#include <pipewire/proxy.h>
#ifdef __cplusplus
extern "C" {
#endif
/** \defgroup pw_factory Factory
* Factory interface
*/

View file

@ -5,6 +5,8 @@
#ifndef PIPEWIRE_I18N_H
#define PIPEWIRE_I18N_H
#include <spa/support/i18n.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -17,7 +19,6 @@ extern "C" {
* \addtogroup pw_gettext
* \{
*/
#include <spa/support/i18n.h>
SPA_FORMAT_ARG_FUNC(1) const char *pw_gettext(const char *msgid);
SPA_FORMAT_ARG_FUNC(1) const char *pw_ngettext(const char *msgid, const char *msgid_plural, unsigned long int n);

View file

@ -5,12 +5,12 @@
#ifndef PIPEWIRE_IMPL_CLIENT_H
#define PIPEWIRE_IMPL_CLIENT_H
#include <spa/utils/hook.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/hook.h>
/** \page page_client_impl Client Implementation
*
* \see \ref pw_impl_client

View file

@ -7,14 +7,14 @@
#ifndef PIPEWIRE_IMPL_MODULE_H
#define PIPEWIRE_IMPL_MODULE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/hook.h>
#include <pipewire/context.h>
#ifdef __cplusplus
extern "C" {
#endif
#define PIPEWIRE_SYMBOL_MODULE_INIT "pipewire__module_init"
#define PIPEWIRE_MODULE_PREFIX "libpipewire-"

View file

@ -5,12 +5,12 @@
#ifndef PIPEWIRE_IMPL_PORT_H
#define PIPEWIRE_IMPL_PORT_H
#include <spa/utils/hook.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/hook.h>
/** \defgroup pw_impl_port Port Impl
*
* \brief A port can be used to link two nodes.

View file

@ -5,11 +5,12 @@
#ifndef PIPEWIRE_KEYS_H
#define PIPEWIRE_KEYS_H
#include <pipewire/utils.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <pipewire/utils.h>
/**
* \defgroup pw_keys Key Names
*

View file

@ -5,15 +5,15 @@
#ifndef PIPEWIRE_LINK_H
#define PIPEWIRE_LINK_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <pipewire/proxy.h>
#ifdef __cplusplus
extern "C" {
#endif
/** \defgroup pw_link Link
*
* A link is the connection between 2 nodes (\ref pw_node). Nodes are

View file

@ -5,13 +5,13 @@
#ifndef PIPEWIRE_LOOP_H
#define PIPEWIRE_LOOP_H
#include <spa/support/loop.h>
#include <spa/utils/dict.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/support/loop.h>
#include <spa/utils/dict.h>
/** \defgroup pw_loop Loop
*
* PipeWire loop object provides an implementation of

View file

@ -5,16 +5,16 @@
#ifndef PIPEWIRE_MAP_H
#define PIPEWIRE_MAP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <string.h>
#include <errno.h>
#include <spa/utils/defs.h>
#include <pipewire/array.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef PW_API_MAP
#define PW_API_MAP static inline
#endif

View file

@ -5,15 +5,15 @@
#ifndef PIPEWIRE_MODULE_H
#define PIPEWIRE_MODULE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <pipewire/proxy.h>
#ifdef __cplusplus
extern "C" {
#endif
/** \defgroup pw_module Module
* Module interface
*/

View file

@ -5,10 +5,6 @@
#ifndef PIPEWIRE_NODE_H
#define PIPEWIRE_NODE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#include <errno.h>
@ -19,6 +15,10 @@ extern "C" {
#include <pipewire/proxy.h>
#ifdef __cplusplus
extern "C" {
#endif
/** \defgroup pw_node Node
* Node interface
*/

View file

@ -5,12 +5,12 @@
#ifndef PIPEWIRE_PERMISSION_H
#define PIPEWIRE_PERMISSION_H
#include <spa/utils/defs.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
/** \defgroup pw_permission Permission
*
* Permissions are kept for a client and describe what the client is

View file

@ -5,10 +5,6 @@
#ifndef PIPEWIRE_H
#define PIPEWIRE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/support/plugin.h>
#include <pipewire/array.h>
@ -41,6 +37,10 @@ extern "C" {
#include <pipewire/utils.h>
#include <pipewire/version.h>
#ifdef __cplusplus
extern "C" {
#endif
/** \defgroup pw_pipewire Initialization
* Initializing PipeWire and loading SPA modules.
*/

View file

@ -5,10 +5,6 @@
#ifndef PIPEWIRE_PORT_H
#define PIPEWIRE_PORT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#include <errno.h>
@ -18,6 +14,10 @@ extern "C" {
#include <pipewire/proxy.h>
#ifdef __cplusplus
extern "C" {
#endif
/** \defgroup pw_port Port
* Port interface
*/

View file

@ -7,10 +7,6 @@
/** \privatesection */
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/socket.h>
#include <sys/types.h> /* for pthread_t */
@ -24,6 +20,10 @@ extern "C" {
#include <spa/utils/result.h>
#include <spa/utils/type-info.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__FreeBSD__) || defined(__MidnightBSD__) || defined(__GNU__)
struct ucred {
};

View file

@ -5,16 +5,16 @@
#ifndef PIPEWIRE_PROPERTIES_H
#define PIPEWIRE_PROPERTIES_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#include <spa/utils/cleanup.h>
#include <spa/utils/dict.h>
#include <spa/utils/string.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef PW_API_PROPERTIES
#define PW_API_PROPERTIES static inline
#endif

View file

@ -5,12 +5,12 @@
#ifndef PIPEWIRE_PROTOCOL_H
#define PIPEWIRE_PROTOCOL_H
#include <spa/utils/list.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/list.h>
/** \defgroup pw_protocol Protocol
*
* \brief Manages protocols and their implementation

View file

@ -5,12 +5,12 @@
#ifndef PIPEWIRE_PROXY_H
#define PIPEWIRE_PROXY_H
#include <spa/utils/hook.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/hook.h>
/** \page page_proxy Proxy
*
* \see \ref pw_proxy

View file

@ -5,12 +5,12 @@
#ifndef PIPEWIRE_RESOURCE_H
#define PIPEWIRE_RESOURCE_H
#include <spa/utils/hook.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/hook.h>
/** \defgroup pw_resource Resource
*
* \brief Client owned objects

View file

@ -5,12 +5,12 @@
#ifndef PIPEWIRE_THREAD_LOOP_H
#define PIPEWIRE_THREAD_LOOP_H
#include <pipewire/loop.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <pipewire/loop.h>
/** \page page_thread_loop Thread Loop
*
* \see \ref pw_thread_loop

View file

@ -5,15 +5,15 @@
#ifndef PIPEWIRE_THREAD_H
#define PIPEWIRE_THREAD_H
#ifdef __cplusplus
extern "C" {
#endif
#include <string.h>
#include <errno.h>
#include <spa/support/thread.h>
#ifdef __cplusplus
extern "C" {
#endif
/** \defgroup pw_thread Thread
*
* \brief functions to manipulate threads

View file

@ -5,12 +5,12 @@
#ifndef PIPEWIRE_TYPE_H
#define PIPEWIRE_TYPE_H
#include <spa/utils/type.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/type.h>
/** \defgroup pw_type Type info
* Type information
*/

View file

@ -5,10 +5,6 @@
#ifndef PIPEWIRE_UTILS_H
#define PIPEWIRE_UTILS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <string.h>
#include <sys/un.h>
@ -17,14 +13,18 @@ extern "C" {
#endif
#include <errno.h>
#ifndef ENODATA
#define ENODATA 9919
#endif
#include <spa/utils/cleanup.h>
#include <spa/utils/defs.h>
#include <spa/pod/pod.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef ENODATA
#define ENODATA 9919
#endif
/** \defgroup pw_utils Utilities
*
* Various utility functions