<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title></title>
<style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<p>On 2016-11-28 06:32, Filip Roséen wrote:</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> Using `sizeof` is not really what you want, you should compare the
*max*/*min* value of the two types in order to properly check if the
value will fit.
It is far too early in the morning, and I have as usual not slept for
what seems like days and days.. but the below should reflect what you
want.
#if LUA_MININTEGER > INT64_MIN || LUA_MAXINTEGER < INT64_MAX
if( val.i_int < LUA_MININTEGER || val.i_int > LUA_MAXINTEGER )
lua_pushnumber( L, (lua_Number)val.i_int );
else
#else
lua_pushinteger( L, val.i_int );
#endif</code></pre>
</blockquote>
<p>Erhm, the usage of <code>#else</code> and <code>#endif</code> is of course wrong; the below is more like it:</p>
<pre><code>#if LUA_MININTEGER > INT64_MIN || LUA_MAXINTEGER < INT64_MAX
if( val.i_int < LUA_MININTEGER || val.i_int > LUA_MAXINTEGER )
lua_pushnumber( L, (lua_Number)val.i_int );
else
#endif
lua_pushinteger( L, val.i_int );</code></pre>
<p>I guess I just proved my own point related to me needing some sleep, and with that.. <code>/me goes to bed</code>.</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> Given that we, *afaik*, do not have a `macro` related to the *max* and
*min* of `vlc_value_t::i_int`, the above uses `INT64_MAX` and
`INT64_MIN` (which is the valid range for the *data-member* in
question) directly.</code></pre>
</blockquote>
</body>
</html>