Commit b3a3da37 authored by Chun-wei Fan's avatar Chun-wei Fan Committed by Martin Pitt
Browse files

gi/pygi-marshal-from-py.c: Fix build on Visual C++

Since Visual C++ does not provide the INFINITY and NAN constants in its
math.h (they are items defined by C99), provide fallback implementations
for it here.  The INFINITY constant can be provided with HUGE_VAL, since
we are using INFINITY to check the value of a variable of double type, and
we could use a rather simple workaround for NAN.

Also avoid declaring variables in the middle of the block.
parent 5210e3d5
......@@ -32,6 +32,22 @@
#include "pygi-marshal-cleanup.h"
#include "pygi-marshal-from-py.h"
#ifdef _WIN32
#ifdef _MSC_VER
#include <math.h>
#ifndef NAN
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
#define NAN (*(const float *) __nan)
#ifndef INFINITY
static gboolean
gi_argument_from_py_ssize_t (GIArgument *arg_out,
Py_ssize_t size_in,
......@@ -1388,10 +1404,11 @@ _pygi_destroy_notify_create (void)
if (!global_destroy_notify) {
PyGICClosure *destroy_notify = g_slice_new0 (PyGICClosure);
GIBaseInfo* glib_destroy_notify;
g_assert (destroy_notify);
GIBaseInfo* glib_destroy_notify = g_irepository_find_by_name (NULL, "GLib", "DestroyNotify");
glib_destroy_notify = g_irepository_find_by_name (NULL, "GLib", "DestroyNotify");
g_assert (glib_destroy_notify != NULL);
g_assert (g_base_info_get_type (glib_destroy_notify) == GI_INFO_TYPE_CALLBACK);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment