Fix compiler warnings and errors in GCC.
This commit is contained in:
parent
462f6eb9a8
commit
0be620602a
3 changed files with 27 additions and 4 deletions
|
|
@ -25,6 +25,10 @@ struct check_segment_alignment {
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct capn_segment *create(void *u, uint32_t id, int sz) {
|
static struct capn_segment *create(void *u, uint32_t id, int sz) {
|
||||||
|
// Silence warnings about unused parameters.
|
||||||
|
UNUSED(u);
|
||||||
|
UNUSED(id);
|
||||||
|
|
||||||
struct capn_segment *s;
|
struct capn_segment *s;
|
||||||
sz += sizeof(*s);
|
sz += sizeof(*s);
|
||||||
if (sz < 4096) {
|
if (sz < 4096) {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
* of the MIT license. See the LICENSE file for details.
|
* of the MIT license. See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||||
|
|
||||||
#include "capnp_c.h"
|
#include "capnp_c.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,12 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// ssize_t is defined in unistd.h in GCC.
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(unix) && !defined(__APPLE__)
|
#if defined(unix) && !defined(__APPLE__)
|
||||||
#include <endian.h>
|
#include <endian.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -22,6 +28,19 @@
|
||||||
typedef intmax_t ssize_t;
|
typedef intmax_t ssize_t;
|
||||||
#endif
|
#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
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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
|
* data, len, cap, and user should all set by the user. Other values
|
||||||
* should be zero initialized.
|
* should be zero initialized.
|
||||||
*/
|
*/
|
||||||
#ifdef _MSC_VER
|
|
||||||
__declspec(align(64))
|
struct ALIGNED_(64) capn_segment {
|
||||||
#endif
|
|
||||||
struct capn_segment {
|
|
||||||
struct capn_tree hdr;
|
struct capn_tree hdr;
|
||||||
struct capn_segment *next;
|
struct capn_segment *next;
|
||||||
struct capn *capn;
|
struct capn *capn;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue