A few days ago a colleague of mine asked me to help with strange errors his C++ project kept throwing at him.
Since it was a C++ project we had more than 200 compilation errors but as the C++ veterans that we are we’ve ignored most of them and scrolled up until we’ve found the patient zero of the issue – inside an header file that looked something like this:
MyClassWP8& operator=(const MyClassWP8&) = delete;
MyClassWP8(const MyClassWP8&) = delete;
MyClassWP8(MyClassWP8&&) = delete;
Do you see the problem? – me neither.
If you’re not familiar with delete/default keyword (for a method), it’s a (relatively) new functionality added as part of C++ 11.
In C++11, defaulted and deleted functions give you explicit control over whether the special member functions are automatically generated. Deleted functions also give you simple language to prevent problematic type promotions from occurring in arguments to functions of all types—special member functions, as well as normal member functions and non-member functions—which would otherwise cause an unwanted function call.
Back in the days of VS2012 this functionality was not supported but since we were using VS2013 there was no apparent reason for it not to work.
We’ve verified that VS2013 support default/delete in desktop, WP8.1 and even Windows Phone Silverlght 8.1 applications. However when using the good old Windows Phone 8.0 application the code refused to compile.
After enabling verbose build (Properties –> C/C++ –> General –> Suppress startup logo == No) I found the reason for the issue – while all of the projects used the newest C/C++ compiler
Windows Phone 8.0 projects used and older compiler version that do not support some of C++11 features including explicitly deleted functions.
this is both logical and annoying at the same time – I guess that’s one more reason to upgrade to WP8.1.