Ask Your Question

Revision history [back]

Release build error (MVSC2012 update 5) - expected a type specifier (cvstd.hpp)

Hi All,

I'm getting some build error in my application (using OpenCV 3.0) when I compile it in release mode (MT runtime library, Visual Studio Express 2012 Update 5). The build is fine in Debug mode (MTd). The two builds link against the proper static libraries ("d" for debug, not for release) and the error happens before the linking stage, in the cvstd.hpp file.

This is a x64 build and WIN32 is defined (one of the libraries needs it).

Error in cvstd.hpp @ line 155: expected a type specifier

/*!
  The STL-compilant memory Allocator based on cv::fastMalloc() and cv::fastFree()
*/
template<typename _Tp> class Allocator
{
public:
    typedef _Tp value_type;
    typedef value_type* pointer;
    typedef const value_type* const_pointer;
    typedef value_type& reference;
    typedef const value_type& const_reference;
    typedef size_t size_type;
    typedef ptrdiff_t difference_type;
    template<typename U> class rebind { typedef Allocator<U> other; };

    explicit Allocator() {}
    ~Allocator() {}
    explicit Allocator(Allocator const&) {}
    template<typename U>
    explicit Allocator(Allocator<U> const&) {}

    // address
    pointer address(reference r) { return &r; }
    const_pointer address(const_reference r) { return &r; }

    pointer allocate(size_type count, const void* =0) { return reinterpret_cast<pointer>(fastMalloc(count * sizeof (_Tp))); }
    void deallocate(pointer p, size_type) { fastFree(p); }

    void construct(pointer p, const _Tp& v) { new(static_cast<void*>(p)) _Tp(v); }
    void destroy(pointer p) { p->~_Tp(); }

    size_type max_size() const { return cv::max(static_cast<_Tp>(-1)/sizeof(_Tp), 1); }
};

The error is at the void construct(...) line.

void construct(pointer p, const _Tp& v) { new(static_cast<void*>(p)) _Tp(v); }

I have no idea if it's a bug, an incompatibility with VC2012 STL implementation, or what?

I tried the 2.4.9, with same results.

Anybody?

Thanks!