Skip to content

Commit fb082b1

Browse files
thesamesamfalkTX
authored andcommitted
Don't include headers within 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. See https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/2377 in PipeWire where they bundle some JACK headers, so came across this.
1 parent cae58ca commit fb082b1

File tree

12 files changed

+41
-49
lines changed

12 files changed

+41
-49
lines changed

common/driver_interface.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,16 @@
2121
#ifndef __jack_driver_interface_h__
2222
#define __jack_driver_interface_h__
2323

24-
#ifdef __cplusplus
25-
extern "C"
26-
{
27-
#endif
28-
2924
#include <limits.h>
3025
#include "jslist.h"
3126

3227
#include "JackCompilerDeps.h"
3328
#include "JackSystemDeps.h"
3429

30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
3534
#define JACK_DRIVER_NAME_MAX 15
3635
#define JACK_DRIVER_PARAM_NAME_MAX 15
3736
#define JACK_DRIVER_PARAM_STRING_MAX 127

common/jack/intclient.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
#ifndef __jack_intclient_h__
2121
#define __jack_intclient_h__
2222

23+
#include <jack/types.h>
24+
2325
#ifdef __cplusplus
2426
extern "C"
2527
{
2628
#endif
2729

28-
#include <jack/types.h>
29-
3030
/**
3131
* Get an internal client's name. This is useful when @ref
3232
* JackUseExactName was not specified on jack_internal_client_load()

common/jack/jack.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@
2121
#ifndef __jack_h__
2222
#define __jack_h__
2323

24+
#include <jack/systemdeps.h>
25+
#include <jack/types.h>
26+
#include <jack/transport.h>
27+
#include <jack/weakmacros.h>
28+
2429
#ifdef __cplusplus
2530
extern "C"
2631
{
2732
#endif
2833

29-
#include <jack/systemdeps.h>
30-
#include <jack/types.h>
31-
#include <jack/transport.h>
32-
3334
/**
3435
* Note: More documentation can be found in jack/types.h.
3536
*/
@@ -46,8 +47,6 @@ extern "C"
4647
* <jack/weakjack.h> before jack.h.
4748
*************************************************************/
4849

49-
#include <jack/weakmacros.h>
50-
5150
/**
5251
* Call this function to get version of the JACK, in form of several numbers
5352
*

common/jack/midiport.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@
2121
#ifndef __JACK_MIDIPORT_H
2222
#define __JACK_MIDIPORT_H
2323

24-
#ifdef __cplusplus
25-
extern "C" {
26-
#endif
27-
2824
#include <jack/weakmacros.h>
2925
#include <jack/types.h>
3026
#include <stdlib.h>
3127

28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
3231

3332
/** Type for raw event data contained in @ref jack_midi_event_t. */
3433
typedef unsigned char jack_midi_data_t;

common/jack/net.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@
2020
#ifndef __net_h__
2121
#define __net_h__
2222

23-
#ifdef __cplusplus
24-
extern "C"
25-
{
26-
#endif
27-
2823
#include <jack/systemdeps.h>
2924
#include <jack/types.h>
3025
#include <jack/weakmacros.h>
3126

27+
#ifdef __cplusplus
28+
extern "C" {
29+
#endif
30+
3231
#define DEFAULT_MULTICAST_IP "225.3.19.154"
3332
#define DEFAULT_PORT 19000
3433
#define DEFAULT_MTU 1500

common/jack/ringbuffer.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@
2121
#ifndef _RINGBUFFER_H
2222
#define _RINGBUFFER_H
2323

24+
#include <sys/types.h>
25+
2426
#ifdef __cplusplus
25-
extern "C"
26-
{
27+
extern "C" {
2728
#endif
2829

29-
#include <sys/types.h>
30-
3130
/** @file ringbuffer.h
3231
*
3332
* A set of library functions to make lock-free ringbuffers available

common/jack/session.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
#ifndef __jack_session_h__
2222
#define __jack_session_h__
2323

24+
#include <jack/types.h>
25+
#include <jack/weakmacros.h>
26+
2427
#ifdef __cplusplus
2528
extern "C" {
2629
#endif
2730

28-
#include <jack/types.h>
29-
#include <jack/weakmacros.h>
30-
3131
/**
3232
* @defgroup SessionClientFunctions Session API for clients.
3333
*

common/jack/statistics.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@
2121
#ifndef __statistics_h__
2222
#define __statistics_h__
2323

24+
#include <jack/types.h>
25+
2426
#ifdef __cplusplus
25-
extern "C"
26-
{
27+
extern "C" {
2728
#endif
2829

29-
#include <jack/types.h>
30-
3130
/**
3231
* @return the maximum delay reported by the backend since
3332
* startup or reset. When compared to the period size in usecs, this

common/jack/thread.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
#ifndef __jack_thread_h__
2121
#define __jack_thread_h__
2222

23+
#include <jack/systemdeps.h>
24+
#include <jack/weakmacros.h>
25+
2326
#ifdef __cplusplus
2427
extern "C"
2528
{
2629
#endif
2730

28-
#include <jack/systemdeps.h>
29-
#include <jack/weakmacros.h>
30-
3131
/* use 512KB stack per thread - the default is way too high to be feasible
3232
* with mlockall() on many systems */
3333
#define THREAD_STACK 524288

common/jack/transport.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
#ifndef __jack_transport_h__
2222
#define __jack_transport_h__
2323

24+
#include <jack/types.h>
25+
#include <jack/weakmacros.h>
26+
2427
#ifdef __cplusplus
2528
extern "C" {
2629
#endif
2730

28-
#include <jack/types.h>
29-
#include <jack/weakmacros.h>
30-
3131
/**
3232
* @defgroup TransportControl Transport and Timebase control
3333
* @{

0 commit comments

Comments
 (0)