FLTK 1.4.0
Loading...
Searching...
No Matches
fl_casts.H
1//
2// Experimental inline "cast functions" for the Fast Light Toolkit (FLTK).
3// See also issue #109: "VS2017 warnings when building fltk 1.4.x"
4//
5// Copyright 1998-2021 by Bill Spitzak and others.
6//
7// This library is free software. Distribution and use rights are outlined in
8// the file "COPYING" which should have been included with this file. If this
9// file is missing or damaged, see the license at:
10//
11// https://www.fltk.org/COPYING.php
12//
13// Please see the following page on how to report bugs and issues:
14//
15// https://www.fltk.org/bugs.php
16//
17
18#ifndef _FL_fl_casts_H_
19#define _FL_fl_casts_H_
20
21#include <FL/platform_types.h>
22
23inline char fl_char(void *v) { return (char)(fl_intptr_t)v; }
24inline int fl_int(void *v) { return (int)(fl_intptr_t)v; }
25inline long fl_long(void *v) { return (long)(fl_intptr_t)v; }
26
27inline unsigned char fl_uchar(void *v) { return (unsigned char)(fl_uintptr_t)v; }
28inline unsigned int fl_uint(void *v) { return (unsigned int)(fl_uintptr_t)v; }
29inline unsigned long fl_ulong(void *v) { return (unsigned long)(fl_uintptr_t)v; }
30
31// the following conversions can be used to silence MSVC warning C4312:
32// 'type cast': conversion from '<type>' to 'void *' of greater size
33
34inline void *fl_voidptr(int v) { return (void *)(fl_intptr_t)v; }
35inline void *fl_voidptr(unsigned int v) { return (void *)(fl_uintptr_t)v; }
36inline void *fl_voidptr(long v) { return (void *)(fl_intptr_t)v; }
37inline void *fl_voidptr(unsigned long v) { return (void *)(fl_uintptr_t)v; }
38
39#endif /* _FL_fl_casts_H_ */
Definitions of platform-dependent types.
opaque fl_uintptr_t
An unsigned integral type large enough to store a pointer or an unsigned long value.
Definition platform_types.h:36
opaque fl_intptr_t
An integral type large enough to store a pointer or a long value.
Definition platform_types.h:31