From 3ae98978d43ed845b12dcd998f82e36c47a81174 Mon Sep 17 00:00:00 2001 From: Sergey Shambir Date: Fri, 19 Apr 2013 13:56:27 +0400 Subject: [PATCH] Added CC_FORMAT_PRINTF to CCString Added for CCString::initWithFormat() and CCString::createWithFormat(). Fixed warnings. --- cocos2dx/cocoa/CCString.h | 4 ++-- cocos2dx/label_nodes/CCLabelBMFont.cpp | 5 ++--- cocos2dx/platform/CCPlatformMacros.h | 6 ++++++ cocos2dx/shaders/CCGLProgram.cpp | 5 ++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cocos2dx/cocoa/CCString.h b/cocos2dx/cocoa/CCString.h index 895a96cf35..13a63884af 100644 --- a/cocos2dx/cocoa/CCString.h +++ b/cocos2dx/cocoa/CCString.h @@ -54,7 +54,7 @@ public: CCString& operator= (const CCString& other); /** init a string with format, it's similar with the c function 'sprintf' */ - bool initWithFormat(const char* format, ...); + bool initWithFormat(const char* format, ...) CC_FORMAT_PRINTF(2, 3); /** convert to int value */ int intValue() const; @@ -95,7 +95,7 @@ public: * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. */ - static CCString* createWithFormat(const char* format, ...); + static CCString* createWithFormat(const char* format, ...) CC_FORMAT_PRINTF(1, 2); /** create a string with binary data * @return A CCString pointer which is an autorelease object pointer, diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 6d21292619..6d7fd93436 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -45,7 +45,6 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only) using namespace std; - NS_CC_BEGIN // The return value needs to be deleted by CC_SAFE_DELETE_ARRAY. @@ -153,8 +152,8 @@ CCBMFontConfiguration::~CCBMFontConfiguration() const char* CCBMFontConfiguration::description(void) { return CCString::createWithFormat( - "", - this, + "", + (size_t)this, HASH_COUNT(m_pFontDefDictionary), HASH_COUNT(m_pKerningDictionary), m_sAtlasName.c_str() diff --git a/cocos2dx/platform/CCPlatformMacros.h b/cocos2dx/platform/CCPlatformMacros.h index 78abab8a84..503cfbe353 100644 --- a/cocos2dx/platform/CCPlatformMacros.h +++ b/cocos2dx/platform/CCPlatformMacros.h @@ -259,6 +259,12 @@ public: virtual void set##funName(varType var) \ #define CC_FORMAT_PRINTF(formatPos, argPos) #endif +#if defined(_MSC_VER) +#define CC_FORMAT_PRINTF_SIZE_T "%08lX" +#else +#define CC_FORMAT_PRINTF_SIZE_T "%08zX" +#endif + #ifdef __GNUC__ #define CC_UNUSED __attribute__ ((unused)) #else diff --git a/cocos2dx/shaders/CCGLProgram.cpp b/cocos2dx/shaders/CCGLProgram.cpp index eca5c32873..85c11e51fa 100644 --- a/cocos2dx/shaders/CCGLProgram.cpp +++ b/cocos2dx/shaders/CCGLProgram.cpp @@ -130,7 +130,10 @@ bool CCGLProgram::initWithVertexShaderFilename(const char* vShaderFilename, cons const char* CCGLProgram::description() { - return CCString::createWithFormat("", this, m_uProgram, m_uVertShader, m_uFragShader)->getCString(); + return CCString::createWithFormat("", + (size_t)this, m_uProgram, m_uVertShader, m_uFragShader)->getCString(); } bool CCGLProgram::compileShader(GLuint * shader, GLenum type, const GLchar* source)