[Layout.c/h]: Minor modifications so that the Microsoft compiler can compile the file as C++ directly ;

This commit is contained in:
Pierre Renaux
2015-05-05 18:07:06 +08:00
parent 3859d0ec26
commit ee5e8c1722
2 changed files with 18 additions and 2 deletions

View File

@@ -11,10 +11,17 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdbool.h>
#include "Layout.h" #include "Layout.h"
#ifdef _MSC_VER
#include <float.h>
#define isnan _isnan
__forceinline const float fmaxf(const float a, const float b) {
return (a > b) ? a : b;
}
#endif
bool isUndefined(float value) { bool isUndefined(float value) {
return isnan(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 *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); init_css_node(node);
return node; return node;
} }

View File

@@ -11,7 +11,16 @@
#define __LAYOUT_H #define __LAYOUT_H
#include <math.h> #include <math.h>
#ifndef __cplusplus
#include <stdbool.h> #include <stdbool.h>
#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 #define CSS_UNDEFINED NAN
typedef enum { typedef enum {