Changeset 402 for trunk/src


Ignore:
Timestamp:
06/13/15 21:51:27 (10 years ago)
Author:
epyon
Message:
  • cleanups of clang warnings (gotta love them all)
  • only nv-core for now (this will take a while for the whole source)
  • mainly C++ casts instead of C-style casts, but also a few bugs fixed!
Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/library.cc

    r399 r402  
    1111#   include <windows.h>
    1212#   define NV_LIB_EXT ".dll"
    13 #   define NV_LIB_HANDLE HMODULE
    14 #   define NV_LIB_OPEN( name ) LoadLibraryEx( name, NULL, LOAD_WITH_ALTERED_SEARCH_PATH )
    15 #   define NV_LIB_GET( handle, name ) GetProcAddress( handle, name )
    16 #   define NV_LIB_CLOSE( name ) !FreeLibrary( name )
     13#   define NV_LIB_OPEN( name ) static_cast<void*>( LoadLibraryEx( name, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ) )
     14#   define NV_LIB_GET( handle, name ) reinterpret_cast<void*>( GetProcAddress( static_cast<HMODULE>( handle ), name ) )
     15#   define NV_LIB_CLOSE( handle ) ( FreeLibrary( static_cast<HMODULE>( handle ) ) != 0 )
    1716#elif NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE
    1817#   include <dlfcn.h>
    1918#   define NV_LIB_EXT ".so"
    20 #   define NV_LIB_HANDLE void*
    2119#   define NV_LIB_OPEN( name ) dlopen( name, RTLD_LAZY | RTLD_GLOBAL)
    22 #   define NV_LIB_GET( handle, name ) dlsym( handle, name )
    23 #   define NV_LIB_CLOSE( name ) dlclose( name )
     20#   define NV_LIB_GET( handle, name ) dlsym( static_cast<void*>( handle ), name )
     21#   define NV_LIB_CLOSE( handle ) ( dlclose( static_cast<void*>( handle ) ) == 0 )
    2422#elif NV_PLATFORM == NV_APPLE
    2523#   include "macUtils.h"
    2624#   include <dlfcn.h>
    2725#   define NV_LIB_EXT ".dylib"
    28 #   define NV_LIB_HANDLE CFBundleRef
    2926#   define NV_LIB_OPEN( name ) mac_loadExeBundle( name )
    3027#   define NV_LIB_GET( handle, name ) mac_getBundleSym( handle, name )
    31 #   define NV_LIB_CLOSE( name ) mac_unloadExeBundle( name )
     28#   define NV_LIB_CLOSE( handle ) ( mac_unloadExeBundle( handle ) == 0 )
    3229#endif
    3330
     
    8380    }
    8481
    85     m_handle = (void*)NV_LIB_OPEN( name.c_str() );
     82    m_handle = NV_LIB_OPEN( name.c_str() );
    8683
    8784    if ( m_handle == NULL )
     
    9693void* library::get( string_view symbol )
    9794{
    98         void* result = (void*) NV_LIB_GET( (NV_LIB_HANDLE) m_handle, symbol.data() );
     95        void* result = NV_LIB_GET( m_handle, symbol.data() );
    9996    if ( !result )
    10097    {
     
    106103void* nv::library::try_get( string_view symbol )
    107104{
    108         return (void*) NV_LIB_GET( (NV_LIB_HANDLE) m_handle, symbol.data() );
     105        return NV_LIB_GET( m_handle, symbol.data() );
    109106}
    110107
     
    116113void library::close()
    117114{
    118     if ( NV_LIB_CLOSE( (NV_LIB_HANDLE)m_handle ) )
     115    if ( ! NV_LIB_CLOSE( m_handle ) )
    119116    {
    120117        NV_LOG_ERROR( "library : can't close library '", m_name, "'!" );
    121118    }
    122     m_handle = NULL;
     119    m_handle = nullptr;
    123120}
    124121
    125122library::~library()
    126123{
    127     if ( m_handle != NULL )
     124    if ( m_handle != nullptr )
    128125    {
    129126        close();
     
    135132#if NV_PLATFORM == NV_WINDOWS
    136133    // We do hate WinAPI for code like this, don't we?
    137     LPTSTR buffer = NULL;
     134    LPTSTR buffer = nullptr;
    138135    FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
    139         NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &buffer, 0, NULL );
    140     std::string msg( (char*)buffer );
     136        NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPTSTR>( &buffer ), 0, NULL );
     137    std::string msg( reinterpret_cast<char*>( buffer ) );
    141138    LocalFree( buffer );
    142139    return msg;
    143140#elif NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE
    144     return string(dlerror());
     141    return std::string( dlerror() );
    145142#else
    146     return string("");
     143    return std::string("");
    147144#endif
    148145}
  • trunk/src/core/logger.cc

    r399 r402  
    8989        for ( auto& sink_info : m_log_sinks )
    9090        {
    91                 if ( sink_info.sink && (sink_info.level >= (uint32)level) )
     91                if ( sink_info.sink && (sink_info.level >= static_cast<uint32>( level ) ) )
    9292                {
    9393                        // log and iterate
     
    106106                {
    107107                        sink_info.sink  = sink;
    108                         sink_info.level = (uint32)level;
     108                        sink_info.level = static_cast<uint32>( level );
    109109                        return;
    110110                }
     
    194194        //if ( m_flush ) FlushFileBuffers( m_handle );
    195195#else
    196         fwrite( stamp, ssize, 1, (FILE*)m_handle );
    197         fwrite( " [", 2, 1, (FILE*)m_handle );
    198         fwrite( NV_LOG_LEVEL_NAME_PAD( level ), 8, 1, (FILE*)m_handle );
    199         fwrite( "] ", 2, 1, (FILE*)m_handle );
    200         fwrite( message.data(), message.size(), 1, (FILE*)m_handle );
    201         fwrite( "\n", 1, 1, (FILE*)m_handle );
    202         if ( m_flush ) fflush( (FILE*)m_handle );
     196        FILE* file = static_cast<FILE*>( m_handle );
     197        fwrite( stamp, ssize, 1, file );
     198        fwrite( " [", 2, 1, file );
     199        fwrite( NV_LOG_LEVEL_NAME_PAD( level ), 8, 1, file );
     200        fwrite( "] ", 2, 1, file );
     201        fwrite( message.data(), message.size(), 1, file );
     202        fwrite( "\n", 1, 1, file );
     203        if ( m_flush ) fflush( file );
    203204#endif
    204205}
     
    226227        CloseHandle( m_handle );
    227228#else
    228         fclose( (FILE*) m_handle );
     229        fclose( static_cast<FILE*>( m_handle ) );
    229230#endif
    230231}
     
    244245{
    245246        uint32 ms = get_system_ms();
    246         unsigned int secs = (unsigned int)(ms / 1000);
    247         unsigned int mm   = (unsigned int)( ms * 100 / 1000 ) % 100;
    248         unsigned int h    = (unsigned int)(secs / (60*60));
    249         unsigned int m    = (unsigned int)(secs / 60) % 60;
     247        unsigned int secs = static_cast<unsigned int>( ms / 1000 );
     248        unsigned int mm   = static_cast<unsigned int>( ms * 100 / 1000 ) % 100;
     249        unsigned int h    = static_cast<unsigned int>( secs / (60*60) );
     250        unsigned int m    = static_cast<unsigned int>( secs / 60 ) % 60;
    250251        unsigned int s    = secs % 60;
    251252#if NV_COMPILER == NV_MSVC
  • trunk/src/core/profiler.cc

    r399 r402  
    124124                if ( c->m_calls > 0 )
    125125                {
    126                         f64 pparent = ( (f64)c->m_total_time_us / (f64)c->m_parent->m_total_time_us ) * 100.f;
     126                        f64 ftotal_time_us = static_cast<f64>( c->m_total_time_us );
     127                        f64 pparent = ( ftotal_time_us / static_cast<f64>( c->m_parent->m_total_time_us ) ) * 100.f;
    127128                        uint32 calls       = c->m_calls;
    128                         f64 total_ms = c->m_total_time_us / 1000.f;
    129                         f64 avg_ms = ( (f64)c->m_total_time_us / (f64)c->m_calls ) / 1000.f;
     129                        f64 total_ms = ftotal_time_us / 1000.f;
     130                        f64 avg_ms = ( ftotal_time_us / static_cast<f64>( c->m_calls ) ) / 1000.f;
    130131                        if ( indent > 0 ) nvmemset( buffer, '-', indent );
    131132                        snprintf( buffer + indent, 128 - indent, "%*.*s %6.2f %6d %9.2f %6.2f", indent - 23, 23 - indent,
  • trunk/src/core/random.cc

    r395 r402  
    1919random::seed_type random::randomize()
    2020{
    21         std::mt19937& rng = *(( std::mt19937* )m_data);
     21        std::mt19937& rng = *( reinterpret_cast< std::mt19937* >( m_data ) );
    2222        seed_type seed = randomized_seed();
    2323        rng.seed( seed );
     
    2727void random::set_seed( random::seed_type seed /*= 0 */ )
    2828{
    29         std::mt19937& rng = *( ( std::mt19937* )m_data );
     29        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    3030        rng.seed( seed == 0 ? randomized_seed() : seed );
    3131}
     
    3939random::result_type random::rand()
    4040{
    41         std::mt19937& rng = *( ( std::mt19937* )m_data );
     41        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    4242        return rng();
    4343}
     
    4545sint32 random::srand( sint32 val )
    4646{
    47         std::mt19937& rng = *( ( std::mt19937* )m_data );
     47        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    4848        std::uniform_int_distribution<sint32> dist( 0, val - 1 );
    4949        return dist( rng );
     
    5252uint32 random::urand( uint32 val )
    5353{
    54         std::mt19937& rng = *( ( std::mt19937* )m_data );
     54        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    5555        std::uniform_int_distribution<uint32> dist( 0, val - 1 );
    5656        return dist( rng );
     
    5959f32 random::frand( f32 val )
    6060{
    61         std::mt19937& rng = *( ( std::mt19937* )m_data );
     61        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    6262        std::uniform_real_distribution<f32> dist( 0, val );
    6363        return dist( rng );
     
    6666sint32 random::srange( sint32 min, sint32 max )
    6767{
    68         std::mt19937& rng = *( ( std::mt19937* )m_data );
     68        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    6969        std::uniform_int_distribution<sint32> dist( min, max );
    7070        return dist( rng );
     
    7373uint32 random::urange( uint32 min, uint32 max )
    7474{
    75         std::mt19937& rng = *( ( std::mt19937* )m_data );
     75        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    7676        std::uniform_int_distribution<uint32> dist( min, max );
    7777        return dist( rng );
     
    8080f32 random::frange( f32 min, f32 max )
    8181{
    82         std::mt19937& rng = *( ( std::mt19937* )m_data );
     82        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    8383        std::uniform_real_distribution<f32> dist( min, max );
    8484        return dist( rng );
     
    8787uint32 random::dice( uint32 count, uint32 sides )
    8888{
    89         std::mt19937& rng = *( ( std::mt19937* )m_data );
     89        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    9090        std::uniform_int_distribution<uint32> dist( 1, sides );
    9191        uint32 result = 0;
     
    106106nv::vec2 nv::random::precise_unit_vec2()
    107107{
    108         std::mt19937& rng = *( ( std::mt19937* )m_data );
     108        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    109109        std::uniform_real_distribution<f32> dist( 0, glm::pi<float>() * 2.f );
    110110        float angle = dist( rng );
     
    114114nv::vec3 nv::random::precise_unit_vec3()
    115115{
    116         std::mt19937& rng = *( ( std::mt19937* )m_data );
     116        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    117117        std::uniform_real_distribution<f32> dist11( -1.0f, 1.0f );
    118118        std::uniform_real_distribution<f32> dist02pi( 0.0f, 2*glm::pi<float>() );
     
    129129nv::vec2 nv::random::fast_disk_point()
    130130{
    131         std::mt19937& rng = *( ( std::mt19937* )m_data );
     131        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    132132        std::uniform_real_distribution<f32> dist( 0.0f, 1.0f );
    133133        float r1 = dist( rng );
     
    140140nv::vec2 nv::random::precise_disk_point()
    141141{
    142         std::mt19937& rng = *( ( std::mt19937* )m_data );
     142        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    143143        std::uniform_real_distribution<f32> unit( 0.0f, 1.0f );
    144144        std::uniform_real_distribution<f32> angle( 0.0f, glm::pi<float>() );
     
    150150nv::vec3 nv::random::fast_sphere_point()
    151151{
    152         std::mt19937& rng = *( ( std::mt19937* )m_data );
     152        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    153153        std::uniform_real_distribution<f32> dist01( 0.0f, 1.0f );
    154154        std::uniform_real_distribution<f32> dist11( -1.0f, 1.0f );
     
    168168nv::vec3 nv::random::precise_sphere_point()
    169169{
    170         std::mt19937& rng = *( ( std::mt19937* )m_data );
     170        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    171171        std::uniform_real_distribution<f32> dist01( 0.0f, 1.0f );
    172172        std::uniform_real_distribution<f32> dist11( -1.0f, 1.0f );
     
    185185nv::vec2 nv::random::precise_ellipse_point( const vec2& radii )
    186186{
    187         std::mt19937& rng = *( ( std::mt19937* )m_data );
     187        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    188188        std::uniform_real_distribution<f32> distx( -radii.x, radii.x );
    189189        std::uniform_real_distribution<f32> disty( -radii.y, radii.y );
     
    204204nv::vec3 nv::random::precise_ellipsoid_point( const vec3& radii )
    205205{
    206         std::mt19937& rng = *( ( std::mt19937* )m_data );
     206        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    207207        std::uniform_real_distribution<f32> distx( -radii.x, radii.x );
    208208        std::uniform_real_distribution<f32> disty( -radii.y, radii.y );
     
    225225nv::vec2 nv::random::fast_hollow_disk_point( float iradius, float oradius )
    226226{
    227         std::mt19937& rng = *( ( std::mt19937* )m_data );
     227        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    228228        float idist2 = iradius * iradius;
    229229        float odist2 = oradius * oradius;
     
    239239nv::vec3 nv::random::fast_hollow_sphere_point( float iradius, float oradius )
    240240{
    241         std::mt19937& rng = *( ( std::mt19937* )m_data );
     241        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    242242        float idist3 = iradius * iradius * iradius;
    243243        float odist3 = oradius * oradius * oradius;
     
    254254nv::vec2 nv::random::fast_hollow_ellipse_point( const vec2& iradii, const vec2& oradii )
    255255{
    256         std::mt19937& rng = *( ( std::mt19937* )m_data );
     256        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    257257        vec2 iradii2 = iradii * iradii;
    258258        vec2 opoint     = ellipse_edge( oradii );
     
    275275nv::vec3 nv::random::fast_hollow_ellipsoid_point( const vec3& iradii, const vec3& oradii )
    276276{
    277         std::mt19937& rng = *( ( std::mt19937* )m_data );
     277        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    278278        vec3 iradii2 = iradii * iradii;
    279279        vec3 opoint     = ellipsoid_edge( oradii );
  • trunk/src/core/time.cc

    r401 r402  
    8585nv::uint32 nv::get_cpu_ms()
    8686{
    87         return (uint32)( (f32)( clock() - zero_timer.clock_zero ) / ( (f32)CLOCKS_PER_SEC / 1000.0 ) ) ;
     87        return static_cast<uint32>( static_cast<f32>( clock() - zero_timer.clock_zero ) / ( static_cast<f32>(CLOCKS_PER_SEC) / 1000.0f ) ) ;
    8888}
    8989
    9090nv::uint64 nv::get_cpu_us()
    9191{
    92         return (uint64)( (f32)( clock() - zero_timer.clock_zero ) / ( (f32)CLOCKS_PER_SEC / 1000000.0 ) ) ;
     92        return static_cast<uint64>( static_cast<f32>( clock() - zero_timer.clock_zero ) / ( static_cast<f32>(CLOCKS_PER_SEC) / 1000000.0f ) ) ;
    9393}
    9494
     
    9999        QueryPerformanceCounter(&now);
    100100        LONGLONG result = now.QuadPart - zero_timer.query_zero.QuadPart;
    101         return (uint32) (1000.0 * result / (double) zero_timer.frequency.QuadPart);
     101        return static_cast<uint32>(1000.0 * result / static_cast<f64>( zero_timer.frequency.QuadPart ) );
    102102#else
    103103        struct timeval now;
    104104        gettimeofday(&now, NULL);
    105         return (uint32)( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000+(now.tv_usec-zero_timer.timeval_zero.tv_usec)/1000 );
     105        return static_cast<uint32>( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000+(now.tv_usec-zero_timer.timeval_zero.tv_usec)/1000 );
    106106#endif
    107107}
     
    113113        QueryPerformanceCounter(&now);
    114114        LONGLONG result = now.QuadPart - zero_timer.query_zero.QuadPart;
    115         return (uint64) (1000000.0 * result / (double) zero_timer.frequency.QuadPart);
     115        return static_cast<uint64>(1000000.0 * result / static_cast<f64>( zero_timer.frequency.QuadPart ) );
    116116#else
    117117        struct timeval now;
    118118        gettimeofday(&now, NULL);
    119         return (uint32)( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000000+(now.tv_usec - zero_timer.timeval_zero.tv_usec) );
     119        return static_cast<uint64>( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000000+(now.tv_usec - zero_timer.timeval_zero.tv_usec) );
    120120#endif
    121121}
  • trunk/src/stl/assert.cc

    r396 r402  
    3131extern "C" {
    3232        extern void __assert(const char *, const char *, unsigned int, const char *)
    33                 throw() __attribute__ ((__noreturn__));
     33                __attribute__ ((__noreturn__));
    3434}
    3535#       else
    3636extern "C" {
    3737        extern void __assert_fail(const char *, const char *, unsigned int, const char *)
    38                 throw() __attribute__ ((__noreturn__));
     38                __attribute__ ((__noreturn__));
    3939}
    4040#       endif
    41 void nv_internal_assert( const char * assertion, const char * file, unsigned int line, const char * function )
     41__attribute__( ( __noreturn__ ) ) void nv_internal_assert( const char * assertion, const char * file, unsigned int line, const char * function )
    4242{
    4343#       if NV_COMPILER == NV_CLANG
  • trunk/src/stl/hash_table.cc

    r395 r402  
    4747};
    4848
    49 static const nv::uint32 s_primes_size = ( sizeof( s_primes ) / sizeof( *s_primes ) );
     49//static const nv::uint32 s_primes_size = ( sizeof( s_primes ) / sizeof( *s_primes ) );
    5050
    5151namespace nv
    5252{
    53         void* g_hash_table_empty[2] = { nullptr, (void*)uintptr_t( ~0 ) };
     53        void* g_hash_table_empty[2] = { nullptr, reinterpret_cast<void*>( uintptr_t( ~0 ) ) };
    5454}
    5555
  • trunk/src/stl/string.cc

    r395 r402  
    1515using namespace nv;
    1616
    17 static const double s_power_10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000,
    18 10000000, 100000000, 1000000000 };
     17//static const double s_power_10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 };
    1918
    2019std::string nv::slurp( const std::string& filename )
     
    4140{
    4241        char* s = str;
    43         uint32 abs = ( n < 0 ) ? (uint32)( -n ) : (uint32)( n );
     42        uint32 abs = static_cast< uint32 >( n < 0 ? -n : n );
    4443        do
    4544        {
    46                 *s++ = (char)( '0' + ( abs % 10 ) );
     45                *s++ = static_cast<char>( '0' + ( abs % 10 ) );
    4746                abs /= 10;
    4847        } while ( abs > 0 );
     
    5049        *s = '\0';
    5150        string_reverse( str, s - 1 );
    52         return (nv::size_t)( s - str );
     51        return static_cast<nv::size_t>( s - str );
    5352}
    5453
     
    5655{
    5756        char* s = str;
    58         uint64 abs = ( n < 0 ) ? (uint64)( -n ) : (uint64)( n );
     57        uint64 abs = static_cast< uint64 >( n < 0 ? -n : n );
    5958        do
    6059        {
    61                 *s++ = (char)( '0' + ( abs % 10 ) );
     60                *s++ = static_cast<char>( '0' + ( abs % 10 ) );
    6261                abs /= 10;
    6362        } while ( abs > 0 );
     
    6564        *s = '\0';
    6665        string_reverse( str, s - 1 );
    67         return (nv::size_t)( s - str );
     66        return static_cast<nv::size_t>( s - str );
    6867}
    6968
     
    7372        do
    7473        {
    75                 *s++ = (char)( '0' + ( n % 10 ) );
     74                *s++ = static_cast<char>( '0' + ( n % 10 ) );
    7675                n /= 10;
    7776        } while ( n > 0 );
    7877        *s = '\0';
    7978        string_reverse( str, s - 1 );
    80         return (nv::size_t)( s - str );
     79        return static_cast<nv::size_t>( s - str );
    8180}
    8281
     
    8685        do
    8786        {
    88                 *s++ = (char)( '0' + ( n % 10 ) );
     87                *s++ = static_cast<char>( '0' + ( n % 10 ) );
    8988                n /= 10;
    9089        } while ( n > 0 );
    9190        *s = '\0';
    9291        string_reverse( str, s - 1 );
    93         return (size_t)( s - str );
     92        return static_cast<nv::size_t>( s - str );
    9493}
    9594
     
    101100        int result = snprintf( str, 64, "%.*g", 6, n );
    102101#endif
    103         return result > 0 ? ( nv::size_t )result : 0;
     102        return static_cast<nv::size_t>( result > 0 ? result : 0 );
    104103}
    105104
     
    111110        int result = snprintf( str, 64, "%.*g", 6, n );
    112111#endif
    113         return result > 0 ? ( nv::size_t )result : 0;
     112        return static_cast<nv::size_t>( result > 0 ? result : 0 );
    114113}
    115114
    116 sint32 buffer_to_sint32( const char* str, char** end )
     115sint32 nv::buffer_to_sint32( const char* str, char** end )
    117116{
    118117        const char* s = str;
     
    131130                ++s;
    132131        }
    133         if ( end != nullptr ) *end = (char*)s;
     132        if ( end != nullptr ) *end = const_cast<char*>( s );
    134133        return positive ? result : -result;
    135134}
    136135
    137 sint64 buffer_to_sint64( const char* s, char** end )
     136sint64 nv::buffer_to_sint64( const char* s, char** end )
    138137{
    139138        while ( *s == ' ' ) ++s;
     
    151150                ++s;
    152151        }
    153         if ( end != nullptr ) *end = (char*)s;
     152        if ( end != nullptr ) *end = const_cast<char*>( s );
    154153        return positive ? result : -result;
    155154}
    156155
    157 uint32 buffer_to_uint32( const char* s, char** end )
     156uint32 nv::buffer_to_uint32( const char* s, char** end )
    158157{
    159158        while ( *s == ' ' ) ++s;
     
    161160        while ( *s >= '0' && *s <= '9' )
    162161        {
    163                 result = ( result * 10 ) + (uint32)( *s - '0' );
     162                result = ( result * 10 ) + static_cast<uint32>( *s - '0' );
    164163                ++s;
    165164        }
    166         if ( end != nullptr ) *end = (char*)s;
     165        if ( end != nullptr ) *end = const_cast<char*>( s );
    167166        return result;
    168167}
    169168
    170 uint64 buffer_to_uint64( const char* s, char** end )
     169uint64 nv::buffer_to_uint64( const char* s, char** end )
    171170{
    172171        while ( *s == ' ' ) ++s;
     
    174173        while ( *s >= '0' && *s <= '9' )
    175174        {
    176                 result = ( result * 10 ) + (uint32)( *s - '0' );
     175                result = ( result * 10 ) + static_cast<uint32>( *s - '0' );
    177176                ++s;
    178177        }
    179         if ( end != nullptr ) *end = (char*)s;
     178        if ( end != nullptr ) *end = const_cast<char*>( s );
    180179        return result;
    181180}
    182181
    183 float buffer_to_f32( const char* s, char** end )
     182float nv::buffer_to_f32( const char* s, char** end )
    184183{
    185184        return strtof( s, end );
    186185}
    187186
    188 double buffer_to_f64( const char* s, char** end )
     187double nv::buffer_to_f64( const char* s, char** end )
    189188{
    190189        return strtod( s, end );
Note: See TracChangeset for help on using the changeset viewer.