Skip to content

Commit 6736fa2

Browse files
committed
Fix build example and test with Visual C++
This change will fix build example and test with Visual C++.
1 parent 1c4e08e commit 6736fa2

File tree

5 files changed

+36
-1
lines changed

5 files changed

+36
-1
lines changed

example/sio_microphone.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ static int prioritized_sample_rates[] = {
4545
0,
4646
};
4747

48-
48+
#ifdef _MSC_VER
49+
__declspec (noreturn)
50+
#else
4951
__attribute__ ((cold))
5052
__attribute__ ((noreturn))
5153
__attribute__ ((format (printf, 1, 2)))
54+
#endif
5255
static void panic(const char *format, ...) {
5356
va_list ap;
5457
va_start(ap, format);

example/sio_record.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
#include <string.h>
1313
#include <math.h>
1414
#include <errno.h>
15+
#ifdef _WIN32
16+
#include <windows.h>
17+
#define sleep(n) Sleep(n * 1000)
18+
#else
1519
#include <unistd.h>
20+
#endif
1621

1722
struct RecordContext {
1823
struct SoundIoRingBuffer *ring_buffer;

test/backend_disconnect_recover.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,20 @@
1212
#include <stdlib.h>
1313
#include <string.h>
1414
#include <math.h>
15+
#ifdef _WIN32
16+
#include <windows.h>
17+
#define sleep(n) Sleep(n * 1000)
18+
#else
1519
#include <unistd.h>
20+
#endif
1621

22+
#ifdef _MSC_VER
23+
__declspec (noreturn)
24+
#else
1725
__attribute__ ((cold))
1826
__attribute__ ((noreturn))
1927
__attribute__ ((format (printf, 1, 2)))
28+
#endif
2029
static void panic(const char *format, ...) {
2130
va_list ap;
2231
va_start(ap, format);

test/overflow.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
#include <stdlib.h>
1313
#include <string.h>
1414
#include <math.h>
15+
#ifdef _WIN32
16+
#include <windows.h>
17+
#define sleep(n) Sleep(n * 1000)
18+
#else
1519
#include <unistd.h>
20+
#endif
1621

1722
static enum SoundIoFormat prioritized_formats[] = {
1823
SoundIoFormatFloat32NE,
@@ -36,9 +41,13 @@ static enum SoundIoFormat prioritized_formats[] = {
3641
SoundIoFormatInvalid,
3742
};
3843

44+
#ifdef _MSC_VER
45+
__declspec (noreturn)
46+
#else
3947
__attribute__ ((cold))
4048
__attribute__ ((noreturn))
4149
__attribute__ ((format (printf, 1, 2)))
50+
#endif
4251
static void panic(const char *format, ...) {
4352
va_list ap;
4453
va_start(ap, format);

test/underflow.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,21 @@
1212
#include <stdlib.h>
1313
#include <string.h>
1414
#include <math.h>
15+
#ifdef _WIN32
16+
#include <windows.h>
17+
#define sleep(n) Sleep(n * 1000)
18+
#else
1519
#include <unistd.h>
20+
#endif
1621
#include <stdint.h>
1722

23+
#ifdef _MSC_VER
24+
__declspec (noreturn)
25+
#else
1826
__attribute__ ((cold))
1927
__attribute__ ((noreturn))
2028
__attribute__ ((format (printf, 1, 2)))
29+
#endif
2130
static void panic(const char *format, ...) {
2231
va_list ap;
2332
va_start(ap, format);

0 commit comments

Comments
 (0)