Index: /trunk/nv.lua
===================================================================
--- /trunk/nv.lua	(revision 203)
+++ /trunk/nv.lua	(revision 204)
@@ -15,4 +15,6 @@
 			buildoptions { 
 				"-std=c++11",
+                                -- on Mac OS X don't try to use old stdc++
+                                "-stdlib=libc++",
 				"-Weverything",
 				-- obviously we don't care about C++98 compatibility
Index: /trunk/nv/common.hh
===================================================================
--- /trunk/nv/common.hh	(revision 203)
+++ /trunk/nv/common.hh	(revision 204)
@@ -108,4 +108,5 @@
 #include <typeinfo>
 #include <cstddef>
+#include <cstdint>
 #include <cassert>
 #include <nv/logging.hh>
@@ -150,17 +151,17 @@
 
 	// Typedefs for fixed size types.
-	typedef signed char         sint8;
-	typedef signed short        sint16;
-	typedef signed long         sint32;
-	typedef signed long long    sint64;
-
-	typedef unsigned char       uint8;
-	typedef unsigned short      uint16;
-	typedef unsigned long       uint32;
-	typedef unsigned long long  uint64;
-
-	typedef unsigned char       char8;
-	typedef unsigned short      char16;
-	typedef unsigned long       char32;
+	typedef int8_t  sint8;
+	typedef int16_t sint16;
+	typedef int32_t sint32;
+	typedef int64_t sint64;
+
+	typedef uint8_t  uint8;
+	typedef uint16_t uint16;
+	typedef uint32_t uint32;
+	typedef uint64_t uint64;
+
+	typedef unsigned char  char8;
+	typedef unsigned short char16;
+	typedef unsigned long  char32;
 
 	typedef float  f32;
Index: /trunk/nv/formats/md5_loader.hh
===================================================================
--- /trunk/nv/formats/md5_loader.hh	(revision 203)
+++ /trunk/nv/formats/md5_loader.hh	(revision 204)
@@ -203,6 +203,6 @@
 		const md5_tc_buffer&    get_texcoords( uint32 mesh_id ) const { return m_meshes[mesh_id].texcoord_buffer; }
 		const md5_index_buffer& get_indices  ( uint32 mesh_id ) const { return m_meshes[mesh_id].index_buffer; }
-		uint32 get_vertex_count( uint32 mesh_id ) const { return m_meshes[mesh_id].position_buffer.size(); }
-		uint32 get_index_count( uint32 mesh_id )  const { return m_meshes[mesh_id].index_buffer.size(); }
+		size_t get_vertex_count( uint32 mesh_id ) const { return m_meshes[mesh_id].position_buffer.size(); }
+		size_t get_index_count( uint32 mesh_id )  const { return m_meshes[mesh_id].index_buffer.size(); }
 	protected:
 		bool prepare_mesh( md5_mesh& mesh );
Index: /trunk/nv/gfx/keyframed_mesh.hh
===================================================================
--- /trunk/nv/gfx/keyframed_mesh.hh	(revision 203)
+++ /trunk/nv/gfx/keyframed_mesh.hh	(revision 204)
@@ -19,5 +19,5 @@
 		keyframed_mesh( context* a_context, keyframed_mesh_data* a_data, program* a_program );
 		mat4 get_tag( const std::string& tag ) const;
-		uint32 get_max_frames() const;
+		size_t get_max_frames() const;
 		void set_frame( uint32 frame );
 		void setup_animation( uint32 start, uint32 count, uint32 fps, bool loop );
Index: /trunk/nv/lua/lua_path.hh
===================================================================
--- /trunk/nv/lua/lua_path.hh	(revision 203)
+++ /trunk/nv/lua/lua_path.hh	(revision 204)
@@ -23,6 +23,6 @@
 			struct element 
 			{
-				uint32 value;
-				uint32 length;
+				size_t value;
+				size_t length;
 				element() : value( 0 ), length( 0 ) {}
 			};
@@ -90,8 +90,8 @@
 		private:
 			void parse();
-			void push( uint32 start, uint32 length );
-			void push( uint32 e );
-			void push( const nv::string& p, uint32 lenght );
-			void push( const char* s, uint32 length );
+			void push( size_t start, size_t length );
+			void push( size_t e );
+			void push( const nv::string& p, size_t lenght );
+			void push( const char* s, size_t length );
 		private:
 			element     m_elements[8];
Index: /trunk/src/formats/md2_loader.cc
===================================================================
--- /trunk/src/formats/md2_loader.cc	(revision 203)
+++ /trunk/src/formats/md2_loader.cc	(revision 204)
@@ -357,5 +357,5 @@
 	uint32 stats_collision  = 0;
 
-	std::vector< sint32 > index_translation( md2->header.num_vertices, -1 );
+	std::vector< sint32 > index_translation( static_cast< uint32 >( md2->header.num_vertices ), -1 );
 
 	m_new_indexes.clear();
Index: /trunk/src/formats/obj_loader.cc
===================================================================
--- /trunk/src/formats/obj_loader.cc	(revision 203)
+++ /trunk/src/formats/obj_loader.cc	(revision 204)
@@ -130,5 +130,5 @@
 };
 
-std::size_t mesh_obj_reader::add_face( uint32* vi, uint32* ti, uint32* ni, size_t count )
+size_t mesh_obj_reader::add_face( uint32* vi, uint32* ti, uint32* ni, size_t count )
 {
 	if ( count < 3 )
@@ -181,6 +181,6 @@
 	std::vector< vec4 >& tg = m_tangent->get();
 
-	std::size_t count  = vp.size();
-	std::size_t tcount = count / 3;
+	size_t count  = vp.size();
+	size_t tcount = count / 3;
 
 	std::vector< vec3 > tan1( count );
@@ -188,9 +188,9 @@
 	tg.resize( count );
 
-	for (std::size_t a = 0; a < tcount; ++a )
-	{
-		uint32 i1 = a * 3;
-		uint32 i2 = a * 3 + 1;
-		uint32 i3 = a * 3 + 2;
+	for (size_t a = 0; a < tcount; ++a )
+	{
+		size_t i1 = a * 3;
+		size_t i2 = a * 3 + 1;
+		size_t i3 = a * 3 + 2;
 
 		// TODO: simplify
Index: /trunk/src/gfx/keyframed_mesh.cc
===================================================================
--- /trunk/src/gfx/keyframed_mesh.cc	(revision 203)
+++ /trunk/src/gfx/keyframed_mesh.cc	(revision 204)
@@ -58,5 +58,5 @@
 }
 
-uint32 keyframed_mesh::get_max_frames() const
+size_t keyframed_mesh::get_max_frames() const
 {
 	return m_data->get_frame_count();
@@ -122,5 +122,5 @@
 void nv::keyframed_mesh::draw( render_state& rstate )
 {
-	nv::uint32 vtx_count = m_data->get_vertex_count();
+	size_t vtx_count = m_data->get_vertex_count();
 	if ( m_gpu_last_frame != m_last_frame )
 	{
Index: /trunk/src/gl/gl_texture2d.cc
===================================================================
--- /trunk/src/gl/gl_texture2d.cc	(revision 203)
+++ /trunk/src/gl/gl_texture2d.cc	(revision 204)
@@ -44,5 +44,5 @@
 void nv::gl_texture2d::bind( size_t slot )
 {
-	glActiveTexture( GL_TEXTURE0 + slot );
+	glActiveTexture( GL_TEXTURE0 + static_cast< GLenum >( slot ) );
 	glBindTexture( GL_TEXTURE_2D, m_name.get_value() );
 }
Index: /trunk/src/gui/gui_style.cc
===================================================================
--- /trunk/src/gui/gui_style.cc	(revision 203)
+++ /trunk/src/gui/gui_style.cc	(revision 204)
@@ -48,5 +48,5 @@
 	lua::stack_guard guard( m_lua );
 	if ( !resolve( e, entry, LUA_TNUMBER ) ) return false;
-	i = lua_tointeger( m_lua, -1 );
+	i = static_cast< int >( lua_tointeger( m_lua, -1 ) );
 	return true;
 }
Index: /trunk/src/lib/gl.cc
===================================================================
--- /trunk/src/lib/gl.cc	(revision 203)
+++ /trunk/src/lib/gl.cc	(revision 204)
@@ -37,5 +37,5 @@
 		*(void **) (&ext_loader) = gl_library.get("wglGetProcAddress");
 #		define NV_GL_LOAD_EXT( symbol ) *(void **) (&symbol) = ext_loader(#symbol);
-#	elif NV_PLATFORM == NV_LINUX
+#	elif (NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE)
 #		define NV_GL_LOAD( symbol ) *(void **) (&symbol) = gl_library.get(#symbol);
 		*(void **) (&ext_loader) = gl_library.get("glXGetProcAddress");
Index: /trunk/src/logger.cc
===================================================================
--- /trunk/src/logger.cc	(revision 203)
+++ /trunk/src/logger.cc	(revision 204)
@@ -229,4 +229,6 @@
 #if NV_PLATFORM == NV_WINDOWS 
 	m_handle = GetStdHandle( STD_OUTPUT_HANDLE );
+#else
+  NV_UNUSED( m_handle );
 #endif
 }
Index: /trunk/src/lua/lua_area.cc
===================================================================
--- /trunk/src/lua/lua_area.cc	(revision 203)
+++ /trunk/src/lua/lua_area.cc	(revision 204)
@@ -194,5 +194,5 @@
 static int nlua_area_corners_closure( lua_State* L )
 {
-	int index = lua_tointeger( L, lua_upvalueindex(2) ) + 1;
+	int index = static_cast< int >( lua_tointeger( L, lua_upvalueindex(2) ) + 1 );
 	lua_pushinteger( L, index );
 	lua_replace( L, lua_upvalueindex(2) ); // update
@@ -223,5 +223,5 @@
 {
 	nv::rectangle* a = nlua_to_parea( L, 1 );
-	a->shrink( lua_tointeger( L, 2 ) );
+	a->shrink( static_cast< int >( lua_tointeger( L, 2 ) ) );
 	return 0;
 }
@@ -230,5 +230,5 @@
 {
 	nv::rectangle* a = nlua_to_parea( L, 1 );
-	nlua_push_area( L, a->shrinked( lua_tointeger( L, 2 ) ) );
+	nlua_push_area( L, a->shrinked( static_cast< int >( lua_tointeger( L, 2 ) ) ) );
 	return 1;
 }
@@ -237,5 +237,5 @@
 {
 	nv::rectangle* a = nlua_to_parea( L, 1 );
-	a->expand( lua_tointeger( L, 2 ) );
+	a->expand( static_cast< int >( lua_tointeger( L, 2 ) ) );
 	return 0;
 }
@@ -244,5 +244,5 @@
 {
 	nv::rectangle* a = nlua_to_parea( L, 1 );
-	nlua_push_area( L, a->expanded( lua_tointeger( L, 2 ) ) );
+	nlua_push_area( L, a->expanded( static_cast< int >( lua_tointeger( L, 2 ) ) ) );
 	return 1;
 }
@@ -327,5 +327,5 @@
 {
 	nv::ivec2 c = nlua_to_coord( L, 1 );
-	int amount = lua_tointeger( L, 1 );
+	int amount = static_cast< int >( lua_tointeger( L, 1 ) );
 	nv::ivec2 shift( amount, amount );
 	nlua_push_area( L, nv::rectangle( c - shift, c + shift ) );
Index: /trunk/src/lua/lua_aux.cc
===================================================================
--- /trunk/src/lua/lua_aux.cc	(revision 203)
+++ /trunk/src/lua/lua_aux.cc	(revision 204)
@@ -91,6 +91,6 @@
 static int nluaaux_math_dieroll( lua_State* L )
 {
-	int dice  = luaL_checkinteger( L,  1 );
-	int sides = luaL_checkinteger( L,  2 );
+	lua_Integer dice  = luaL_checkinteger( L,  1 );
+	lua_Integer sides = luaL_checkinteger( L,  2 );
 	if ( dice < 1 )  luaL_argerror( L, 1, "die count lower than 1!" );
 	if ( sides < 1 ) luaL_argerror( L, 2, "side count lower than 1!" );
@@ -109,5 +109,5 @@
 		if ( lua_gettop( L ) == 1 )
 		{
-			int arg1 = luaL_checkinteger( L, 1 );
+			lua_Integer arg1 = luaL_checkinteger( L, 1 );
 			if ( arg1 < 1 ) arg1 = 1;
 			lua_pushunsigned( L, nv::random::get().urange( 1, static_cast<nv::uint32>( arg1 ) ) );
@@ -115,6 +115,6 @@
 		else
 		{
-			int arg1 = luaL_checkinteger( L, 1 );
-			int arg2 = luaL_checkinteger( L, 2 );
+			int arg1 = static_cast< int >( luaL_checkinteger( L, 1 ) );
+			int arg2 = static_cast< int >( luaL_checkinteger( L, 2 ) );
 			if (arg2 < arg1) std::swap( arg2, arg1 );
 			lua_pushinteger( L, nv::random::get().srange( arg1, arg2 ) );
Index: /trunk/src/lua/lua_path.cc
===================================================================
--- /trunk/src/lua/lua_path.cc	(revision 203)
+++ /trunk/src/lua/lua_path.cc	(revision 204)
@@ -44,5 +44,5 @@
 }
 
-void lua::path::push( uint32 e )
+void lua::path::push( size_t e )
 {
 	m_elements[ m_count ].value  = e;
@@ -51,5 +51,5 @@
 }
 
-void lua::path::push( uint32 start, uint32 length )
+void lua::path::push( size_t start, size_t length )
 {
 	m_elements[ m_count ].value  = start;
@@ -58,5 +58,5 @@
 }
 
-void lua::path::push( const char* p, uint32 length )
+void lua::path::push( const char* p, size_t length )
 {
 	m_elements[ m_count ].value  = m_path.length();
@@ -66,5 +66,5 @@
 }
 
-void lua::path::push( const std::string& s, uint32 length )
+void lua::path::push( const std::string& s, size_t length )
 {
 	m_elements[ m_count ].value  = m_path.length();
Index: /trunk/src/lua/lua_state.cc
===================================================================
--- /trunk/src/lua/lua_state.cc	(revision 203)
+++ /trunk/src/lua/lua_state.cc	(revision 204)
@@ -249,7 +249,7 @@
 {
 	lua_getfield( L->L, -1, element.c_str() );
-	int result = lua_type( L->L, -1 ) == LUA_TNUMBER ? lua_tointeger( L->L, -1 ) : defval;
-	lua_pop( L->L, 1 );
-	return result;
+	lua_Integer result = lua_type( L->L, -1 ) == LUA_TNUMBER ? lua_tointeger( L->L, -1 ) : defval;
+	lua_pop( L->L, 1 );
+	return static_cast< int >( result );
 }
 
