std::exception(const char *const&, int) second parameter??

I am using VC++2008 Express and for std::exception's constructor, there is a second parameter of type int. What is this parameter? In the definition of the class I found this code:
1
2
3
4
5
6
7
8
9
10
11
    __CLR_OR_THIS_CALL exception();
    __CLR_OR_THIS_CALL exception(const char *const&);
    __CLR_OR_THIS_CALL exception(const char *const&, int); //The constructor in question
    __CLR_OR_THIS_CALL exception(const exception&);
    exception& __CLR_OR_THIS_CALL operator=(const exception&);
    virtual __CLR_OR_THIS_CALL ~exception();
    virtual const char * __CLR_OR_THIS_CALL what() const;
#endif /* _M_CEE_PURE */
private:
	const char *_m_what;
	int _m_doFree; //What is this? 
At first I thought this wasn't needed, but then when I throw exceptions in my DLLs and catch them in the calling app, if I do not pass this parameter, it crashes after throwing the exception. Passing 1 for this parameter stops the crash. What is this second parameter and why do I need to pass it for my DLL & Calling App to not crash?



EDIT: http://msdn.microsoft.com/en-us/library/c4ts6d5a(v=VS.90).aspx says:
The int parameter allows you to specify that no memory should be allocated. The value of the int is ignored.

However, I'd still like to know why it would crash if I did not use this constructor.
Last edited on
However, I'd still like to know why it would crash if I did not use this constructor.

Let's see is that constructor standard? No.
Do you have to use it? Yes.
Congratulations you've tainted your code for MS.
So should I derive from std::exception and make my own exception class?

EDIT: Well, really I don't need that much for a simple test project. I'm just going to directly throw string literals and catch them as const char *const& for this little test project...
Last edited on
Topic archived. No new replies allowed.