Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3046

A static global variable in a DLL

$
0
0
Am I doing something stupid here?? The following code is in a DLL:-

Code:

// In a header file while building the DLL (i.e. assume that
// LIBTEMPORAL_API handles import or export, as appropriate)

namespace Temporal {

        typedef int64_t superclock_t;

        static superclock_t _superclock_ticks_per_second = 282240000;

        LIBTEMPORAL_API void set_superclock_ticks_per_second (superclock_t sc);

}


// In one of the DLL's source files
void
Temporal::set_superclock_ticks_per_second (Temporal::superclock_t sc)
{
        _superclock_ticks_per_second = sc; // <--- Never changes the value of _superclock_ticks_per_second  !!!!
}

It's almost as if _superclock_ticks_per_second is being treated as const (or are static globals in a DLL automatically const ??

Viewing all articles
Browse latest Browse all 3046

Trending Articles