Add BLI_compiler_compat.h to help with portability

This commit is contained in:
Campbell Barton
2014-05-02 01:14:15 +10:00
parent 35ca209152
commit 95b93b5d46
8 changed files with 37 additions and 26 deletions

View File

@@ -63,10 +63,6 @@
#include <math.h>
#include <string.h>
#ifdef WIN32
# include "BLI_alloca.h"
#endif
/* number of layers to add when growing a CustomData object */
#define CUSTOMDATA_GROW 5

View File

@@ -28,9 +28,6 @@
*/
/* BLI_array_alloca / alloca */
#ifdef _MSC_VER
# define alloca _alloca
#endif
#if defined(__MINGW32__)
# include <malloc.h> /* mingw needs for alloca() */

View File

@@ -0,0 +1,35 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BLI_COMPILER_COMPAT_H__
#define __BLI_COMPILER_COMPAT_H__
/** \file BLI_compiler_compat.h
* \ingroup bli
*
* Use to help with cross platform portability.
*/
#if defined(_MSC_VER)
# define __func__ __FUNCTION__
# define alloca _alloca
#endif
#endif /* __BLI_COMPILER_COMPAT_H__ */

View File

@@ -34,6 +34,7 @@
/* avoid many includes for now */
#include "BLI_sys_types.h"
#include "BLI_compiler_compat.h"
#ifndef NDEBUG /* for BLI_assert */
#include <stdio.h>
@@ -386,16 +387,9 @@
#define STRCASEEQLEN(a, b, n) (strncasecmp(a, b, n) == 0)
#define STRPREFIX(a, b) (strncmp((a), (b), strlen(b)) == 0)
/* useful for debugging */
#define AT __FILE__ ":" STRINGIFY(__LINE__)
/* so we can use __func__ everywhere */
#if defined(_MSC_VER)
# define __func__ __FUNCTION__
#endif
/* UNUSED macro, for function argument */
#ifdef __GNUC__

View File

@@ -116,6 +116,7 @@ set(SRC
BLI_buffer.h
BLI_callbacks.h
BLI_compiler_attrs.h
BLI_compiler_compat.h
BLI_convexhull2d.h
BLI_dlrbTree.h
BLI_dynlib.h

View File

@@ -56,10 +56,6 @@
#include "BLI_utildefines.h"
#ifdef WIN32
# include "BLI_alloca.h"
#endif
#include "BLI_smallhash.h"
#include "BLI_strict_flags.h"

View File

@@ -40,10 +40,6 @@
#include "BKE_editmesh.h"
#include "BKE_multires.h"
#ifdef WIN32
# include "BLI_alloca.h"
#endif
#include "intern/bmesh_private.h"
/* used as an extern, defined in bmesh.h */

View File

@@ -68,10 +68,6 @@
#include "screen_intern.h"
#ifdef WIN32
# include "BLI_alloca.h"
#endif
extern void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); /* xxx temp */
/* general area and region code */