1. Robin Wellner
  2. selove

Commits

Bill Meltsner  committed 792236b

Add LOVE_UNUSED macro to stamp out all those "unused parameter" warnings

  • Participants
  • Parent commits 82340e8
  • Branches default

Comments (0)

Files changed (6)

File src/common/Exception.cpp

View file
  • Ignore whitespace
 **/
 
 #include "Exception.h"
+#include <common/config.h>
 
 namespace love
 {
 
 	Exception::Exception(int unparsed, const char * str)
 	{
+		LOVE_UNUSED(unparsed);
 		strncpy(buffer, str, BUFFER_SIZE);
 	}
 

File src/common/config.h

View file
  • Ignore whitespace
 #	define _CRT_SECURE_NO_WARNINGS
 #endif
 
+#ifndef LOVE_UNUSED
+#	define LOVE_UNUSED(x) (void)sizeof(x)
+#endif
+
 #ifndef LOVE_BUILD
 #	define LOVE_BUILD
 #	define LOVE_BUILD_STANDALONE

File src/modules/graphics/opengl/Graphics.cpp

View file
  • Ignore whitespace
 		//	glEnable (GL_POLYGON_SMOOTH);
 		//	glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
 		//}
+		LOVE_UNUSED(style);
 	}
 
 	void Graphics::setLine( float width, Graphics::LineStyle style )

File src/modules/graphics/opengl/VertexBuffer.cpp

View file
  • Ignore whitespace
 #include "VertexBuffer.h"
 
 #include "common/Exception.h"
+#include <common/config.h>
 
 #include <cstdlib>
 #include <cstring>
 	}
 
 	// VertexBuffer::Bind
-
-	VertexBuffer::Bind::Bind(VertexBuffer &buf)
-		: buf(buf)
-	{
-		buf.bind();
-	}
-
+
+	VertexBuffer::Bind::Bind(VertexBuffer &buf)
+		: buf(buf)
+	{
+		buf.bind();
+	}
+
 	VertexBuffer::Bind::~Bind()
 	{
 		buf.unbind();
 		delete [] buf;
 	}
 
-	void *VertexArray::map(GLenum access)
-	{
-		return buf;
-	}
-
-	void VertexArray::unmap()
-	{
-	}
-
-	void VertexArray::bind()
-	{
-	}
-
-	void VertexArray::unbind()
-	{
-	}
-
+	void *VertexArray::map(GLenum access)
+	{
+		LOVE_UNUSED(access);
+		return buf;
+	}
+
+	void VertexArray::unmap()
+	{
+	}
+
+	void VertexArray::bind()
+	{
+	}
+
+	void VertexArray::unbind()
+	{
+	}
+
 	void VertexArray::fill(int offset, int size, const void *data)
 	{
 		memcpy(buf + offset, data, size);
 			unload(false);
 	}
 
-	void *VBO::map(GLenum access)
-	{
-		// Don't map twice.
-		if (mapped)
-			return mapped;
-
-		mapped = glMapBufferARB(getTarget(), access);
-
-		return mapped;
-	}
-
-	void VBO::unmap()
-	{
-		glUnmapBufferARB(getTarget());
-		mapped = 0;
-	}
-
-	void VBO::bind()
-	{
-		glBindBufferARB(getTarget(), vbo);
-	}
-
-	void VBO::unbind()
-	{
-		glBindBufferARB(getTarget(), 0);
-	}
-
+	void *VBO::map(GLenum access)
+	{
+		// Don't map twice.
+		if (mapped)
+			return mapped;
+
+		mapped = glMapBufferARB(getTarget(), access);
+
+		return mapped;
+	}
+
+	void VBO::unmap()
+	{
+		glUnmapBufferARB(getTarget());
+		mapped = 0;
+	}
+
+	void VBO::bind()
+	{
+		glBindBufferARB(getTarget(), vbo);
+	}
+
+	void VBO::unbind()
+	{
+		glBindBufferARB(getTarget(), 0);
+	}
+
 	void VBO::fill(int offset, int size, const void *data)
 	{
 		if (mapped)
 		return reinterpret_cast<const void*>(offset);
 	}
 
-	bool VBO::loadVolatile()
-	{
-		return load(true);
-	}
-
-	void VBO::unloadVolatile()
-	{
-		unload(true);
+	bool VBO::loadVolatile()
+	{
+		return load(true);
 	}
 
-	bool VBO::load(bool restore)
-	{
-		glGenBuffersARB(1, &vbo);
-
-		VertexBuffer::Bind bind(*this);
-
-		// Copy the old buffer only if 'restore' was requested.
-		const GLvoid *src = restore ? buffer_copy : 0;
-		
-		// Note that if 'src' is '0', no data will be copied.
-		glBufferDataARB(getTarget(), getSize(), src, getUsage());
-
+	void VBO::unloadVolatile()
+	{
+		unload(true);
+	}
+
+	bool VBO::load(bool restore)
+	{
+		glGenBuffersARB(1, &vbo);
+
+		VertexBuffer::Bind bind(*this);
+
+		// Copy the old buffer only if 'restore' was requested.
+		const GLvoid *src = restore ? buffer_copy : 0;
+		
+		// Note that if 'src' is '0', no data will be copied.
+		glBufferDataARB(getTarget(), getSize(), src, getUsage());
+
 		// Clean up buffer_copy, if it exists.
 		delete[] buffer_copy;
-		buffer_copy = 0;
-
-		return true;
-	}
-
+		buffer_copy = 0;
+
+		return true;
+	}
+
 	void VBO::unload(bool save)
 	{
 		// Clean up buffer_copy, if it exists.

File src/modules/thread/sdl/threads.h

View file
  • Ignore whitespace
 #define LOVE_THREAD_SDL_THREADS_H
 
 #include "SDL.h"
+#include <common/config.h>
 
 namespace love
 {
 	class Mutex {
 	private:
 		SDL_mutex* mutex;
-		Mutex(const Mutex& mutex) {}
+		Mutex(const Mutex& mutex) {LOVE_UNUSED(mutex);}
 
 		friend class Conditional;
 
 	class ThreadBase {
 	private:
 		SDL_Thread* thread;
-		ThreadBase(ThreadBase& thread) {}
+		ThreadBase(ThreadBase& thread) {LOVE_UNUSED(thread);}
 		bool running;
 
 		static int thread_runner(void* param);
 
 	class Semaphore {
 	private:
-		Semaphore(const Semaphore& sem) {}
+		Semaphore(const Semaphore& sem) {LOVE_UNUSED(sem);}
 		SDL_sem* semaphore;
 
 	public:

File src/modules/thread/threads.h

View file
  • Ignore whitespace
 	private:
 		Mutex* mutex;
 
-		Lock(Lock& lock) {}
+		Lock(Lock& lock) {LOVE_UNUSED(lock);}
 
 	public:
 		Lock(Mutex* m): mutex(m) {