- Using the Windows Runtime from C++
- Writing modern C++ code : How C++ has evolved over the years
- Bringing existing C++ code into Metro style apps
- Under the covers with C++ for Metro style apps
- Tips and tricks for developing Metro style apps using C++
- Taming GPU compute with C++ AMP
- Going Native 2: C++ at BUILD, WIndows Runtime Library (WRL)
Friday, September 30, 2011
C++ Videos from BUILD 2011
I been watch a lot of the video from the the talks at BUILD. Here is a list of some of the C++ related video from BUILD 2011 that I found interesting
Monday, September 26, 2011
Multi Commander v1.2.0
Multi Commander v1.2.0 is released. This release contains mostly bug fixes. Over 160+ changes has gone into this release.
It might take some time until the next version is ready. Because the next version will be a major update with larger new features and new extensions.
There might be a version 1.2.1 before the then, But that will be a release that only fixes bugs and minor problems. No new additions.
It might take some time until the next version is ready. Because the next version will be a major update with larger new features and new extensions.
There might be a version 1.2.1 before the then, But that will be a release that only fixes bugs and minor problems. No new additions.
Tuesday, September 13, 2011
C++11 Feature support in VC11
Today it was released what C++11 feature that VC11 will support.
The expection was that a lot more would be support. Only 3 new feature sinces VC10.
A lot of people displayd the disapointnemt in the commentsand rightfully so. I think that more could be expected from a company as big as Microsoft.
The the 3 new feature is not everything that is new. If we look at the bright side of things we get more from STL, We get the new AMP that is very intressting, and we get the <filesystem> header from TR2 , that will give us the Boost.Filesystem V2, and that is good.
The new threading support via the <thread> header will be there and that is something I look forward to use.
So even if the new feature for VC11 is not what we expected it is not all bad.
And with the BUILD conference starting today. I expect that we will get lot more news about developing with Windows 8 soon.
The expection was that a lot more would be support. Only 3 new feature sinces VC10.
A lot of people displayd the disapointnemt in the commentsand rightfully so. I think that more could be expected from a company as big as Microsoft.
The the 3 new feature is not everything that is new. If we look at the bright side of things we get more from STL, We get the new AMP that is very intressting, and we get the <filesystem> header from TR2 , that will give us the Boost.Filesystem V2, and that is good.
The new threading support via the <thread> header will be there and that is something I look forward to use.
So even if the new feature for VC11 is not what we expected it is not all bad.
And with the BUILD conference starting today. I expect that we will get lot more news about developing with Windows 8 soon.
Saturday, September 10, 2011
Smart Pointer - unique_ptr
With C++11, There is no reason anymore to use 'delete', and you should try to avoid it.
C++11 gives us a couple of smart pointers, use them and your code will be better and safer.
unique_ptr is the basic replacement for the standard pointer.
It holds a unique pointer and will delete it when it goes out of scope.
If you need to hold multiple instances of the same pointer the you should use shared_ptr instead. But often unique_ptr is enough.
You then use the pointer as you normal would.
If you need the raw pointer.
If you want to remove a pointer from the smart pointer, you need to release the ownership of it.
If you want to move the ownership from own uniqe_ptr to another you need to use the STL helper function std::move.
You should NOT do this. If you do, you will shot yourself in the foot.
What about arrays?
Arrays must be delete using delete[], and unique_ptr will do that, As long as you defined it with the type.
Example
pReader and pData will be automatically be deleted.
C++11 gives us a couple of smart pointers, use them and your code will be better and safer.
unique_ptr is the basic replacement for the standard pointer.
It holds a unique pointer and will delete it when it goes out of scope.
If you need to hold multiple instances of the same pointer the you should use shared_ptr instead. But often unique_ptr is enough.
std::unique_ptr<MyClass> pObj(new MyClass);delete for this will be called when pObj is destroyed.
You then use the pointer as you normal would.
pObj->Method1(); pObj->Method2();
If you need the raw pointer.
MyClass* pRawPtr = pObj.get();But do not call delete on pRawPtr your self.
If you want to remove a pointer from the smart pointer, you need to release the ownership of it.
pObj.release();The std::unique_ptr will now not delete the pointer. And pObj is now also invalid for usage.
If you want to move the ownership from own uniqe_ptr to another you need to use the STL helper function std::move.
std::unique_ptr<MyClass> pObj2; pObj2 = std::move(pObj); // or you could do std::unique_ptr<MyClass> pObj2(pObj.release());Now pObj2 owns it. and pObj does not point to anything anymore.
You should NOT do this. If you do, you will shot yourself in the foot.
std::unique_ptr<MyClass> pObj2(pObj.get());pObj and pObj2 both owns the same pointer. And it will be deleted twice.
What about arrays?
Arrays must be delete using delete[], and unique_ptr will do that, As long as you defined it with the type.
std::unique_ptr<char[]> pArray(new char[2000]);delete[] will now be called when pArray gets deleted.
Example
std::unique_ptr<BYTE[]> FileReader::ReadDataFromFile(int nByteToRead)
{
std::unique_ptr<BYTE[]> pBytes(new BYTE[nByteToRead]);
ZeroMemory(pBytes.get(), nByteToRead);
DWORD nBytesRead = 0;
ReadFile(m_hFile, pBytes.get(), nBytesToRead, &nBytesRead, NULL);
return pBytes;
}
std::unique_ptr<FileReader> pReader(new FileReader("filename.txt"));
std::unique_ptr<BYTE[]> pData = pReader->ReadDataFromFile(64000);
pReader and pData will be automatically be deleted.
Friday, August 26, 2011
Windows 8 - File Name Conflict Dialog
The Windows 8 team release some video and information about the new and improved copy process in Windows 8. It is really a nice improvement from Windows 7. However not good enough to kill Multi Commander, It will still be needed if you want full control of your files.
A lot of the comments in the Windows 8 file copy post was about the file name conflict dialog.
And today they released a new post ( Designing the Windows 8 file name collision experience ) where they talk about the design decision behind that dialog. It is a simple dialog but it is not an easy task to get it right.
I have some experience with this my self. I been working on a redesign of the file name conflict dialog for Multi Commander, and it is not easy. There should be enough important information so the user can make a good decision. But to much information will make the dialog hard to read. To little and the user might not know what file to keep/overwrite. It hard to make a good balanced decision here.
A lot of the comments in the Windows 8 file copy post was about the file name conflict dialog.
And today they released a new post ( Designing the Windows 8 file name collision experience ) where they talk about the design decision behind that dialog. It is a simple dialog but it is not an easy task to get it right.
I have some experience with this my self. I been working on a redesign of the file name conflict dialog for Multi Commander, and it is not easy. There should be enough important information so the user can make a good decision. But to much information will make the dialog hard to read. To little and the user might not know what file to keep/overwrite. It hard to make a good balanced decision here.
Tuesday, August 23, 2011
nullptr (c++)
C++11 now finally offers a real null pointer that is type safe.
The old NULL was a define of the value 0, and this is can generate some problems and bugs.
Here is one of the problem that NULL can give you. In this example we got 2 overloads and we want the pointer overload to be called. But if we send NULL to it. We will not get the expected behavior.
By using nullptr that problem will be avoided.
The old NULL was a define of the value 0, and this is can generate some problems and bugs.
Here is one of the problem that NULL can give you. In this example we got 2 overloads and we want the pointer overload to be called. But if we send NULL to it. We will not get the expected behavior.
void method(int *p);
void method(int n);
method(NULL); // what overload is going to be used. ??
// method(int n); will be called.
By using nullptr that problem will be avoided.
void method(int *p); void method(int n); method(nullptr); // method(int* p); will be called.
Tuesday, August 16, 2011
The Importance of Crash Reporting
One of the most useful feature that I implemented into Multi Commander was that if it crashes it will automatically upload the crash dump to my server.
Of all the crash report I received, I never received a mail or forum post from anyone that reported that it crashed when they did X. If Multi Commander did not send a crash report, there would be a whole bounce of bugs that I would not have been informed about and that would not have been fixed.
Having automatic crash reporting is probably the most important feature you can have. Without it you would not find all the weird problem that user can be affected by.
Of all the crash report I received, I never received a mail or forum post from anyone that reported that it crashed when they did X. If Multi Commander did not send a crash report, there would be a whole bounce of bugs that I would not have been informed about and that would not have been fixed.
Having automatic crash reporting is probably the most important feature you can have. Without it you would not find all the weird problem that user can be affected by.
Subscribe to:
Posts (Atom)