From 94f6cc0a0b656ca1234cd0eacd13a65f4c6110d5 Mon Sep 17 00:00:00 2001 From: JackMacWindows Date: Wed, 22 Jul 2020 02:11:02 -0400 Subject: [PATCH] Fixed MSVC support --- unkrawerter.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/unkrawerter.cpp b/unkrawerter.cpp index 692e66d..f712f19 100644 --- a/unkrawerter.cpp +++ b/unkrawerter.cpp @@ -215,7 +215,14 @@ void readSampleToWAV(FILE* fp, uint32_t offset, const char * filename) { } extern "C" { - typedef struct __attribute__ ((packed)) { +#ifdef _MSC_VER +#pragma pack(push, 1) +#define PACKED +#endif +#ifdef __GNUC__ +#define PACKED __attribute__ ((packed)) +#endif + typedef struct PACKED { uint32_t loopLength; uint32_t size; uint32_t c2Freq; @@ -228,11 +235,11 @@ extern "C" { signed char data[1]; } Sample; - typedef struct __attribute__ ((packed)) { + typedef struct PACKED { unsigned short coord, inc; } EnvNode; - typedef struct __attribute__ ((packed)) { + typedef struct PACKED { EnvNode nodes[ 12 ]; unsigned char max; unsigned char sus; @@ -241,7 +248,7 @@ extern "C" { } Envelope; - typedef struct __attribute__ ((packed)) { + typedef struct PACKED { unsigned short samples[ 96 ]; Envelope envVol; @@ -254,13 +261,13 @@ extern "C" { unsigned char vibRate; } Instrument; - typedef struct __attribute__ ((packed)) { + typedef struct PACKED { unsigned short index[ 16 ]; unsigned short rows; unsigned char data[1]; } Pattern; - typedef struct __attribute__ ((packed)) { + typedef struct PACKED { unsigned char channels; unsigned char numOrders; unsigned char songRestart; @@ -284,6 +291,12 @@ extern "C" { const Pattern* patterns[1]; } Module; +#ifdef _MSC_VER +#pragma pack(pop) +#endif +#ifdef PACKED +#undef PACKED +#endif } Pattern * readPatternFile(FILE* fp, uint32_t offset) { @@ -599,4 +612,4 @@ int main(int argc, const char * argv[]) { } fclose(fp); return 0; -} \ No newline at end of file +}