From ee5e8c1722982943f67e10e612a9f270c48fcc9f Mon Sep 17 00:00:00 2001 From: Pierre Renaux Date: Tue, 5 May 2015 18:07:06 +0800 Subject: [PATCH] [Layout.c/h]: Minor modifications so that the Microsoft compiler can compile the file as C++ directly ; --- src/Layout.c | 11 +++++++++-- src/Layout.h | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Layout.c b/src/Layout.c index 82831b9a..7339e0a6 100644 --- a/src/Layout.c +++ b/src/Layout.c @@ -11,10 +11,17 @@ #include #include #include -#include #include "Layout.h" +#ifdef _MSC_VER +#include +#define isnan _isnan +__forceinline const float fmaxf(const float a, const float b) { + return (a > b) ? a : b; +} +#endif + bool isUndefined(float value) { return isnan(value); } @@ -55,7 +62,7 @@ void init_css_node(css_node_t *node) { } css_node_t *new_css_node() { - css_node_t *node = calloc(1, sizeof(*node)); + css_node_t *node = (css_node_t *)calloc(1, sizeof(*node)); init_css_node(node); return node; } diff --git a/src/Layout.h b/src/Layout.h index 53840947..a75232d6 100644 --- a/src/Layout.h +++ b/src/Layout.h @@ -11,7 +11,16 @@ #define __LAYOUT_H #include +#ifndef __cplusplus #include +#endif + +// Not defined in MSVC++ +#ifndef NAN +static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff}; +#define NAN (*(const float *)__nan) +#endif + #define CSS_UNDEFINED NAN typedef enum {