pack structures in portable fashion, now creates valid bitmap headers for Windows

This commit is contained in:
Robin Stuart 2016-09-10 18:35:45 +01:00
parent 6dbf817ffa
commit 71a30a9031
2 changed files with 18 additions and 22 deletions

View File

@ -43,16 +43,14 @@ extern "C" {
#include <stdint.h> #include <stdint.h>
#endif #endif
#pragma pack (1)
typedef struct bitmap_file_header { typedef struct bitmap_file_header {
uint16_t header_field; uint16_t header_field;
uint32_t file_size; uint32_t file_size;
uint32_t reserved; uint32_t reserved;
uint32_t data_offset; uint32_t data_offset;
} } bitmap_file_header_t;
#ifdef __GNUC__
__attribute__((__packed__))
#endif
bitmap_file_header_t;
typedef struct bitmap_info_header { typedef struct bitmap_info_header {
uint32_t header_size; uint32_t header_size;
@ -66,11 +64,9 @@ extern "C" {
int32_t vert_res; int32_t vert_res;
uint32_t colours; uint32_t colours;
uint32_t important_colours; uint32_t important_colours;
} } bitmap_info_header_t;
#ifdef __GNUC__
__attribute__((__packed__)) #pragma pack ()
#endif
bitmap_info_header_t;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -43,6 +43,8 @@ extern "C" {
#include <stdint.h> #include <stdint.h>
#endif #endif
#pragma pack (1)
typedef struct pcx_header { typedef struct pcx_header {
uint8_t manufacturer; uint8_t manufacturer;
uint8_t version; uint8_t version;
@ -62,11 +64,9 @@ extern "C" {
uint16_t horiz_screen_size; uint16_t horiz_screen_size;
uint16_t vert_screen_size; uint16_t vert_screen_size;
uint8_t filler[54]; uint8_t filler[54];
} } pcx_header_t;
#ifdef __GNUC__
__attribute__((__packed__ )) #pragma pack ()
#endif
pcx_header_t;
#ifdef __cplusplus #ifdef __cplusplus
} }