The code is the documentation

You read/hear that the code should be clear enough to be understood with very little comments. I wholeheartedly agree bu I rarely see code like the one I like to read/write:

// This is less convoluted than what's required for
// std::result_of (deprecated in C++17) or std::invoke_result
using SystemTimer_t = decltype(::SetTimer(HWND{}, UINT_PTR{}, UINT{}, TIMERPROC{}));


m_UpdateUserInterfaceTimerID = SetTimer(UpdateUserInterfaceTimerID, (100ms).count(), nullptr);

What do you think?

Posted in C ++ | Leave a comment

Usefulness of the override keyword…

I just discovered a bug by adding the override to a bunch of virtual function members of an old MFC based UI class: the 3rd-party base class had a LONG_PTR and not a long as we had in our derived class. The code worked fine on 32-bit but it took me time to understand why it was not on 64-bit…

Posted in C ++, Computers and Internet | Leave a comment

Little helper features in Visual Studio

I have now taken the habit to use those and they help me a lot.

The first one is the breakpoint label: I personally use it to associate my bug ticket number with the corresponding breakpoints. When you work on several tickets at the same time and your code base is big, it does help! This Visual Studio 2013: Working with Breakpoint Labels blog entry details this feature.

The second one is the Bookmark window: you can name bookmarks and group them in folders! This one is even more helpful than the first to me! This Setting Bookmarks in Code page has all the details.

Posted in C ++, C#, Computers and Internet | Leave a comment

Ciao Edge…

When I saw that one could get more Microsoft Reward points by using Edge, I started to give it a try, even if they are many UI Chrome features I missed.
After two weeks, I’m going back to Chrome.

Edge 38.14393.0.0 / EdgeHTML 14.14393 is just too unresponsive, crashing at times. I’ll try again in 6 months…

Posted in Uncategorized | Leave a comment

Bring back decent keyboard support please!

When the Palo Alto Network’s GlobalProtect Gateway Login dialog appears with the Username field pre-populated, why can’t I just start typing right away? Why isn’t the focus already set on the empty Password field?

When Atlatlassion’s SourceTree is displaying a status pane during a git pull, pressing the ESC key doesn’t close the “pane” once it’s done pulling the changes from your remote repository. Sure, the ENTER key does but why not the ESC one?

Most Windows 10 store applications support for keyboard users is abysmal. Last century, pressing F1 was taking you to some help. Try that with any of those applications…

Can you all dedicate a bit of resources to support keyboard lover users?

Thank you.


Posted in Computers and Internet, Uncategorized | Leave a comment

C++ 11 auto keyword

Like Hungarian Notation, spaces versus coma indentation, open curly brace position, etc… the usage of the C++ 11 auto keyword, or lack thereof, has a flavor of religious meme.

If you’re in the camp that never uses it, or just with lambdas, or never for built-in types (int, bool, char *, …), can I invite you to follow the related segment of Herb’s excellent Back to the Basics! Essentials of Modern C++ Style talk?

If you’re not yet convinced, acquire or rent the Effective C++ book from Scott Meyers and make sure to read Item 5.

They both make excellent points that show the real values of using auto to declare your variable.Both the video and the book have been available for more than a year and a half now.

I’m telling you, that meme is as strong as the religious one!

Posted in Uncategorized | Leave a comment

Magic Statics

As mentioned in the C++11 Core Language Features Table: Concurrency table, the Magic statics feature is supported under Visual Studio 2015.

Beware that this does not apply to non-local statics (e.g global static variables) and if you’re rightfully concerned about the order of such statics initialization when one depends on the other, a solution is to wrap their access in a static function:

static std::string const & GetString() {
    static std::string const s{"OperationResult"};
    return s;

The assembly that protects the static is:

; 8 : static std::string const s{"OperationResult"};

mov eax, DWORD PTR __tls_index
mov ecx, DWORD PTR fs:__tls_array
mov edx, DWORD PTR [ecx+eax*4]
mov eax, DWORD PTR ?$TSS0@?1??GetString@@YAABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ@4HA
cmp eax, DWORD PTR __Init_thread_epoch[edx]
jle SHORT $LN2@GetString
push OFFSET ?$TSS0@?1??GetString@@YAABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ@4HA
call __Init_thread_header
add esp, 4
cmp DWORD PTR ?$TSS0@?1??GetString@@YAABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ@4HA, -1
jne SHORT $LN2@GetString
mov DWORD PTR __$EHRec$[ebp+8], 0
push OFFSET ??_C@_0BA@PFGBCHGN@OperationResult?$AA@
mov ecx, OFFSET ?s@?1??GetString@@YAABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ@4V23@B
call ??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z ; std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string<char,std::char_traits<char>,std::allocator<char> >
push OFFSET ??__Fs@?1??GetString@@YAABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ@YAXXZ ; `GetString'::`2'::`dynamic atexit destructor for 's''
call _atexit
add esp, 4
mov DWORD PTR __$EHRec$[ebp+8], -1
push OFFSET ?$TSS0@?1??GetString@@YAABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ@4HA
call __Init_thread_footer
add esp, 4


; 9 : return s;
mov eax, OFFSET ?s@?1??GetString@@YAABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ@4V23@B

Finally, have a look at this nice video: C++ Weekly With Jason Turner – Ep 2 Cost of Using Statics

Posted in Computers and Internet | Leave a comment