Fix compiler warnings and errors in GCC.

This commit is contained in:
Alex Helfet 2017-03-22 17:40:05 +00:00
parent 462f6eb9a8
commit 0be620602a
3 changed files with 27 additions and 4 deletions

View file

@ -13,6 +13,12 @@
#include <stdint.h>
#include <stdio.h>
// ssize_t is defined in unistd.h in GCC.
#ifdef __GNUC__
#include <unistd.h>
#endif
#if defined(unix) && !defined(__APPLE__)
#include <endian.h>
#endif
@ -22,6 +28,19 @@
typedef intmax_t ssize_t;
#endif
// Macro UNUSED silences compiler warnings about unused parameters.
#ifndef UNUSED
#define UNUSED(x) (void)(x)
#endif
// Cross-platform macro ALIGNED_(x) aligns a struct by x bits.
#ifdef _MSC_VER
#define ALIGNED_(x) __declspec(align(x))
#endif
#ifdef __GNUC__
#define ALIGNED_(x) __attribute__ ((aligned(x)))
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -103,10 +122,8 @@ struct capn_tree *capn_tree_insert(struct capn_tree *root, struct capn_tree *n);
* data, len, cap, and user should all set by the user. Other values
* should be zero initialized.
*/
#ifdef _MSC_VER
__declspec(align(64))
#endif
struct capn_segment {
struct ALIGNED_(64) capn_segment {
struct capn_tree hdr;
struct capn_segment *next;
struct capn *capn;