Skip to content

Commit

Permalink
All the stuff to make it build with gcc, both native linux and mingw
Browse files Browse the repository at this point in the history
  • Loading branch information
HinTak committed Oct 3, 2021
1 parent d419fb4 commit 0175919
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/FixedMath.h
Expand Up @@ -2,7 +2,11 @@
// Licensed under the MIT License.

#pragma once
#ifndef _WIN32
#define _Inout_
#else
#include <sal.h> // defines _Inout_
#endif

class Fixed2_14
{
Expand Down
11 changes: 9 additions & 2 deletions src/Platform.cpp
Expand Up @@ -7,14 +7,16 @@

#include <time.h>
#include <sys/timeb.h> // _timeb, _ftime
#include <cstdlib> // mbstowcs
#include <cstring> // strlen

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

long long DateTime(void) {
struct _timeb tstruct;
struct timeb tstruct;

// _tzset();
_ftime(&tstruct);
ftime(&tstruct);

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

time(&dateTime);
#ifndef _WIN32
char *cstring = ctime(&dateTime);
mbstowcs(strg, cstring, strlen(cstring));
#else
STRCPYW(strg, _wctime(&dateTime));
#endif
strg[STRLENW(strg) - 1] = L'\0'; // get rid of \n...
} // DateTimeStrg
3 changes: 3 additions & 0 deletions src/TextBuffer.cpp
Expand Up @@ -17,6 +17,9 @@
#include <locale>

#include "TextBuffer.h"
#ifndef _WIN32
#define swprintf(wcs, ...) swprintf(wcs, 1024, __VA_ARGS__)
#endif

#ifndef Min
#define Min(a,b) ((a) < (b) ? (a) : (b))
Expand Down
5 changes: 5 additions & 0 deletions src/pch.h
Expand Up @@ -49,3 +49,8 @@
#define STRSTRW wcsstr
#define STRCHARW wcschr
#define STRCMPW wcscmp

#ifndef _WIN32
#define swprintf(wcs, ...) swprintf(wcs, 1024, __VA_ARGS__)
#define wprintf_s wprintf
#endif

0 comments on commit 0175919

Please sign in to comment.