Skip to content

Commit 0175919

Browse files
committedOct 3, 2021
All the stuff to make it build with gcc, both native linux and mingw
1 parent d419fb4 commit 0175919

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed
 

‎src/FixedMath.h

+4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
// Licensed under the MIT License.
33

44
#pragma once
5+
#ifndef _WIN32
6+
#define _Inout_
7+
#else
58
#include <sal.h> // defines _Inout_
9+
#endif
610

711
class Fixed2_14
812
{

‎src/Platform.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77

88
#include <time.h>
99
#include <sys/timeb.h> // _timeb, _ftime
10+
#include <cstdlib> // mbstowcs
11+
#include <cstring> // strlen
1012

1113
#define TIME_FIX 2082844800ll // pc time 1970 - mac time 1904
1214

1315
long long DateTime(void) {
14-
struct _timeb tstruct;
16+
struct timeb tstruct;
1517

1618
// _tzset();
17-
_ftime(&tstruct);
19+
ftime(&tstruct);
1820

1921
// it seems that we don't have to worry about the time zone, _ftime does that for us
2022
return (long long)tstruct.time + TIME_FIX /* 60*(long)(tstruct.timezone) */;
@@ -24,6 +26,11 @@ void DateTimeStrg(wchar_t strg[]) {
2426
time_t dateTime;
2527

2628
time(&dateTime);
29+
#ifndef _WIN32
30+
char *cstring = ctime(&dateTime);
31+
mbstowcs(strg, cstring, strlen(cstring));
32+
#else
2733
STRCPYW(strg, _wctime(&dateTime));
34+
#endif
2835
strg[STRLENW(strg) - 1] = L'\0'; // get rid of \n...
2936
} // DateTimeStrg

‎src/TextBuffer.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#include <locale>
1818

1919
#include "TextBuffer.h"
20+
#ifndef _WIN32
21+
#define swprintf(wcs, ...) swprintf(wcs, 1024, __VA_ARGS__)
22+
#endif
2023

2124
#ifndef Min
2225
#define Min(a,b) ((a) < (b) ? (a) : (b))

‎src/pch.h

+5
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,8 @@
4949
#define STRSTRW wcsstr
5050
#define STRCHARW wcschr
5151
#define STRCMPW wcscmp
52+
53+
#ifndef _WIN32
54+
#define swprintf(wcs, ...) swprintf(wcs, 1024, __VA_ARGS__)
55+
#define wprintf_s wprintf
56+
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.