Skip to content

Commit 68093b2

Browse files
Backends: Don't forward declare std::thread
Turns out it's undefined behavior, for reference: http://www.gotw.ca/gotw/034.htm On FreeBSD std::thread is forward declared by at least one other standard header we use, but not on GhostBSD. Both make use of a nested inline namespace for library versioning, resulting in std::__1::thread. Basically, there is no portable way to achieve forward declarations for standard containers. The good news is that including the proper header(s) shouldn't slow down compilation at all.
1 parent 4732fbe commit 68093b2

8 files changed

Lines changed: 4 additions & 24 deletions

File tree

src/backends/ALSA/Flux.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <cstddef>
1212
#include <cstring>
1313
#include <functional>
14-
#include <thread>
1514
#include <vector>
1615

1716
#include <alsa/asoundlib.h>

src/backends/ALSA/Flux.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
#include <atomic>
1313
#include <cstdint>
1414
#include <memory>
15-
16-
namespace std {
17-
class thread;
18-
}
15+
#include <thread>
1916

2017
typedef CrossAudio_ErrorCode ErrorCode;
2118

src/backends/OSS/Flux.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <cstdint>
1111
#include <cstring>
1212
#include <functional>
13-
#include <thread>
1413
#include <type_traits>
1514
#include <vector>
1615

src/backends/OSS/Flux.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@
1313

1414
#include <atomic>
1515
#include <memory>
16-
17-
#ifdef __linux__
18-
namespace std {
19-
class thread;
20-
}
21-
#endif
16+
#include <thread>
2217

2318
typedef CrossAudio_ErrorCode ErrorCode;
2419

src/backends/Sndio/Flux.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <cstdint>
1313
#include <cstring>
1414
#include <functional>
15-
#include <thread>
1615
#include <vector>
1716

1817
#include <poll.h>

src/backends/Sndio/Flux.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@
1212
#include <atomic>
1313
#include <cstdint>
1414
#include <memory>
15-
16-
#ifdef __linux__
17-
namespace std {
18-
class thread;
19-
}
20-
#endif
15+
#include <thread>
2116

2217
typedef CrossAudio_ErrorCode ErrorCode;
2318

src/backends/WASAPI/Flux.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <bit>
1212
#include <cstring>
1313
#include <functional>
14-
#include <thread>
1514

1615
#include <Windows.h>
1716

src/backends/WASAPI/Flux.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88

99
#include <atomic>
1010
#include <memory>
11+
#include <thread>
1112

1213
#include "crossaudio/ErrorCode.h"
1314
#include "crossaudio/Flux.h"
1415

15-
namespace std {
16-
class thread;
17-
}
18-
1916
typedef CrossAudio_ErrorCode ErrorCode;
2017

2118
typedef CrossAudio_FluxConfig FluxConfig;

0 commit comments

Comments
 (0)