From 71a30a9031f148131cbc103394b8c2d1f832a424 Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Sat, 10 Sep 2016 18:35:45 +0100 Subject: [PATCH] pack structures in portable fashion, now creates valid bitmap headers for Windows --- backend/bmp.h | 18 +++++++----------- backend/pcx.h | 22 +++++++++++----------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/backend/bmp.h b/backend/bmp.h index 2ab22bf3..dfee3ae7 100644 --- a/backend/bmp.h +++ b/backend/bmp.h @@ -43,16 +43,14 @@ extern "C" { #include #endif +#pragma pack (1) + typedef struct bitmap_file_header { uint16_t header_field; uint32_t file_size; uint32_t reserved; uint32_t data_offset; - } -#ifdef __GNUC__ - __attribute__((__packed__)) -#endif - bitmap_file_header_t; + } bitmap_file_header_t; typedef struct bitmap_info_header { uint32_t header_size; @@ -66,12 +64,10 @@ extern "C" { int32_t vert_res; uint32_t colours; uint32_t important_colours; - } -#ifdef __GNUC__ - __attribute__((__packed__)) -#endif - bitmap_info_header_t; - + } bitmap_info_header_t; + +#pragma pack () + #ifdef __cplusplus } #endif diff --git a/backend/pcx.h b/backend/pcx.h index 0ae9f955..b4e1a002 100644 --- a/backend/pcx.h +++ b/backend/pcx.h @@ -36,13 +36,15 @@ extern "C" { #endif -#ifdef _MSC_VER -#include -#include "stdint_msvc.h" -#else -#include -#endif +#ifdef _MSC_VER +#include +#include "stdint_msvc.h" +#else +#include +#endif +#pragma pack (1) + typedef struct pcx_header { uint8_t manufacturer; uint8_t version; @@ -62,12 +64,10 @@ extern "C" { uint16_t horiz_screen_size; uint16_t vert_screen_size; uint8_t filler[54]; - } -#ifdef __GNUC__ - __attribute__((__packed__ )) -#endif - pcx_header_t; + } pcx_header_t; +#pragma pack () + #ifdef __cplusplus } #endif