I'm wondering if there is a way to get better information about the location of an error in msvc (2005)?
For example, when inheriting from boost::noncopyable in my class I get a C2248 error saying something like:
error C2248: 'boost::noncopyable_::noncopyable::noncopyable' : cannot access private member declared in class 'boost::noncopyable_::noncopyable'. This diagnostic occurred in the compiler generated function 'MyClass::MyClass(const MyClass &)'
but it fail to tell me where exactly the copy constructor was called. This is a little annoying. I'm really not sure but I think I remember seeing a settings somewhere where I could specify the output level or something but I searched and found nothing so my question is: Is there a way to get better (fuller?) error message in msvc?
Edit: Well since stackoverflow just told me I should look to accept an answer, I was wondering if anyone could tell if msvc 2008/2010 give a better diagnostic for this error? Someone also mentioned GCC should do, can anyone confirm this? What about other compilers (Intel?, Comeau?)
Thanks
I can confirm with Code::Blocks and VC++ 2005, that it gives no hint where the error occurs. Neither does declaring your own private copy constructor help.
#include <boost/noncopyable.hpp>
class X: boost::noncopyable
{
};
void foo(X x) {}
int main()
{
X x;
foo(x);
}
The compile log (line five is the last line of the class declaration):
main.cpp(5) : error C2248: 'boost::noncopyable_::noncopyable::noncopyable' : cannot access private member declared in class 'boost::noncopyable_::noncopyable' C:\boost_1_38_0\boost/noncopyable.hpp(27) : see declaration of 'boost::noncopyable_::noncopyable::noncopyable' C:\boost_1_38_0\boost/noncopyable.hpp(22) : see declaration of 'boost::noncopyable_::noncopyable' This diagnostic occurred in the compiler generated function 'X::X(const X &)'
Unless there's a compiler switch to enable more thorough error diagnostics, this wouldn't be the first time for me to simply compile the file with GCC (MinGW) to get more helpful error diagnostics. (Alas, your code should be free of VC++ extensions.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With