fbxsdk/core/arch/fbxstdcompliant.h Source File
 
 
 
fbxsdk/core/arch/fbxstdcompliant.h
Go to the documentation of this file.
00001 /****************************************************************************************
00002  
00003    Copyright (C) 2013 Autodesk, Inc.
00004    All rights reserved.
00005  
00006    Use of this software is subject to the terms of the Autodesk license agreement
00007    provided at the time of installation or download, or which otherwise accompanies
00008    this software in either electronic or hard copy form.
00009  
00010 ****************************************************************************************/
00011 
00014 #ifndef _FBXSDK_CORE_ARCH_STDCOMPLIANT_H_
00015 #define _FBXSDK_CORE_ARCH_STDCOMPLIANT_H_
00016 
00017 #include <fbxsdk/fbxsdk_def.h>
00018 
00019 #include <fbxsdk/fbxsdk_nsbegin.h>
00020 
00021 #if defined(FBXSDK_ENV_WIN)
00022         #define FBXSDK_printf                                                   printf_s
00023         #define FBXSDK_fprintf                                                  fprintf_s
00024         #define FBXSDK_sprintf                                                  sprintf_s
00025         #define FBXSDK_snprintf                                                 _snprintf_s
00026         #define FBXSDK_vsprintf                                                 vsprintf_s
00027         #define FBXSDK_vsnprintf                                                vsnprintf_s
00028         #define FBXSDK_stricmp(dst, src)                                _stricmp(dst, src)
00029         #define FBXSDK_strnicmp(dst, src, count)                _strnicmp(dst, src, count)
00030         #define FBXSDK_strcpy(dst, size, src)                   strcpy_s(dst, size, src)
00031         #define FBXSDK_strncpy(dst, size, src, count)   strncpy_s(dst, size, src, count)
00032         #define FBXSDK_strcat(dst, size, src)                   strcat_s(dst, size, src)
00033         #define FBXSDK_strtok(str, delim, ctx)                  strtok_s(str, delim, ctx)
00034         #define FBXSDK_strdup                                                   _strdup
00035         #define FBXSDK_wcscpy(dst, size, src)                   wcscpy_s(dst, size, src)
00036         #define FBXSDK_wcscat(dst, size, src)                   wcscat_s(dst, size, src)
00037         #define FBXSDK_getpid                                                   _getpid
00038         #define FBXSDK_getcwd                                                   _getcwd
00039         #define FBXSDK_localtime(ptm, time)                             { struct tm tms; ptm = &tms; localtime_s(ptm, time); }
00040         #define FBXSDK_gmtime(ptm, time)                                { struct tm tms; ptm = &tms; gmtime_s(ptm, time); }
00041         #define FBXSDK_fopen(fp, name, mode)                    fopen_s(&fp, name, mode)
00042 
00043 #elif defined(FBXSDK_ENV_MAC) || defined(FBXSDK_ENV_LINUX)
00044         #define FBXSDK_printf                                                   printf
00045         #define FBXSDK_fprintf                                                  fprintf
00046         inline int FBXSDK_sprintf(char* buffer, size_t dummy, const char* format, ...){ va_list vl; va_start(vl, format); int ret = vsprintf(buffer, format, vl); va_end(vl); return ret; }
00047         inline int FBXSDK_snprintf(char* buffer, size_t dummy, size_t count, const char* format, ...){ va_list vl; va_start(vl, format); int ret = vsnprintf(buffer, count, format, vl); va_end(vl); return ret; }
00048         inline int FBXSDK_vsprintf(char* buffer, size_t dummy, const char* format, va_list vl){ return vsprintf(buffer, format, vl); }
00049         inline int FBXSDK_vsnprintf(char* buffer, size_t dummy, size_t count, const char* format, va_list vl){ return vsnprintf(buffer, count, format, vl); }
00050         #define FBXSDK_stricmp(dst, src)                                stricmp(dst, src)
00051         #define FBXSDK_strnicmp(dst, src, count)                strnicmp(dst, src, count)
00052         #define FBXSDK_strcpy(dst, size, src)                   strcpy(dst, src)
00053         #define FBXSDK_strncpy(dst, size, src, count)   strncpy(dst, src, count)
00054         #define FBXSDK_strcat(dst, size, src)                   strcat(dst, src)
00055         #define FBXSDK_strtok(str, delim, ctx)                  strtok(str, delim)
00056         #define FBXSDK_strdup                                                   strdup
00057         #define FBXSDK_wcscpy(dst, size, src)                   wcscpy(dst, src)
00058         #define FBXSDK_wcscat(dst, size, src)                   wcscat_s(dst, src)
00059         #define FBXSDK_getpid                                                   getpid  
00060         #define FBXSDK_getcwd                                                   getcwd
00061         #define FBXSDK_localtime(tm, time)                              tm=localtime(time)
00062         #define FBXSDK_gmtime(tm, time)                                 tm=gmtime(time)
00063         #define FBXSDK_fopen(fp, name, mode)                    fp=fopen(name, mode)
00064 
00065 #else
00066         #error Unsupported platform!
00067 #endif
00068 
00069 //The scanf family functions cannot easily be used in both secure and non-secure versions because
00070 //Microsoft's secure version expects the size of the string/char* arguments following their address.
00071 //On Unix machines the scanf family functions do not have this behavior and trying to use the same
00072 //calls would result in compiler errors because the arguments would not match the format string.
00073 //Using the following macros in the code will simply desable the warning at compile time.
00074 #if defined(FBXSDK_COMPILER_MSC) && (_MSC_VER >= 1300)
00075         #define FBXSDK_CRT_SECURE_NO_WARNING_BEGIN\
00076         {\
00077                 __pragma(warning(push))\
00078                 __pragma(warning(disable : 4996))\
00079         }
00080     
00081         #define FBXSDK_CRT_SECURE_NO_WARNING_END\
00082         {\
00083                 __pragma(warning(pop))\
00084         }
00085 #else
00086         #define FBXSDK_CRT_SECURE_NO_WARNING_BEGIN
00087         #define FBXSDK_CRT_SECURE_NO_WARNING_END
00088 #endif
00089 
00090 #include <fbxsdk/fbxsdk_nsend.h>
00091 
00092 #endif /* _FBXSDK_CORE_ARCH_STDCOMPLIANT_H_ */