Skilled Illusionist
- Joined
- Jul 8, 2008
- Messages
- 306
- Reaction score
- 338
Thanks for sharing, all code are successfully compiled under VS2015 with some code fixes.
Modification of vcruntime_exception.h is required for me to pass linking to std::exception::exception(char const * const&, int).
//
// vcruntime_exception.h
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// <exception> functionality that is implemented in the VCRuntime.
//
#pragma once
#include <eh.h>
#ifdef _M_CEE_PURE
#include <vcruntime_new.h>
#endif
#pragma pack(push, _CRT_PACKING)
#if !defined RC_INVOKED && _HAS_EXCEPTIONS
_CRT_BEGIN_C_HEADER
struct __std_exception_data
{
char const* _What;
bool _DoFree;
};
_VCRTIMP void __cdecl __std_exception_copy(
_In_ __std_exception_data const* _From,
_Out_ __std_exception_data* _To
);
_VCRTIMP void __cdecl __std_exception_destroy(
_Inout_ __std_exception_data* _Data
);
_CRT_END_C_HEADER
namespace std {
class exception
{
public:
exception()
: _Data()
{
}
explicit exception(char const* const _Message)
: _Data()
{
__std_exception_data _InitData = { _Message, true };
__std_exception_copy(&_InitData, &_Data);
}
exception(char const* const _Message, int)
: _Data()
{
_Data._What = _Message;
}
exception(exception const& _Other)
: _Data()
{
__std_exception_copy(&_Other._Data, &_Data);
}
exception& operator=(exception const& _Other)
{
if (this == &_Other)
{
return *this;
}
__std_exception_destroy(&_Data);
__std_exception_copy(&_Other._Data, &_Data);
return *this;
}
virtual ~exception() throw()
{
__std_exception_destroy(&_Data);
}
virtual char const* what() const
{
return _Data._What ? _Data._What : "Unknown exception";
}
private:
__std_exception_data _Data;
};
class bad_exception
: public exception
{
public:
bad_exception() throw()
: exception("bad exception", 1)
{
}
};
class bad_alloc
: public exception
{
public:
bad_alloc() throw()
: exception("bad allocation", 1)
{
}
private:
friend class bad_array_new_length;
bad_alloc(char const* const _Message) throw()
: exception(_Message, 1)
{
}
};
class bad_array_new_length
: public bad_alloc
{
public:
bad_array_new_length() throw()
: bad_alloc("bad array new length")
{
}
};
} // namespace std
#endif // !RC_INVOKED && _HAS_EXCEPTIONS
#pragma pack(pop)
/*
* Copyright (c) 1992-2012 by P.J. Plauger. ALL RIGHTS RESERVED.
* Consult your license regarding permissions and restrictions.
V6.00:0009 */
toexception(char const* const _Message, int)
then everything goes fine.exception(char const* const& _Message, int)
In my case I edited
toCode:exception(char const* const _Message, int)
then everything goes fine.Code:exception(char const* const& _Message, int)
#ifdef _EXTREME_BASKETBALL_FIX_
exception(char const* const& _Message, int)
#else
exception(char const* const _Message, int)
#endif // _EXTREME_BASKETBALL_FIX_
#define _EXTREME_BASKETBALL_FIX_
// vcruntime_exception.h at location [whatever_the_location_is]
// has been modified for this fix with the following:
// #ifdef _EXTREME_BASKETBALL_FIX_
// exception(char const* const& _Message, int)
// #else
// exception(char const* const _Message, int)
// #endif // _EXTREME_BASKETBALL_FIX_
#define _EXTREME_BASKETBALL_FIX_