Posts

Showing posts from 2013

C++ 11's new style, explained by Bjarne Stroustrup

Spanish version / Versión en Español In a series of very interesting presentations in Microsoft's GoingNative2012 event, C++'s main creator, Bjarne Stroustrup himself, talked about the programming style introduced by the brand new C++11 standard. The main focus of Bjarne's presentation was not the new language features , but how to use them correctly; that's what he calls "style". Up next, a summary of the key points raised: Type-rich interfaces: Programmer-defined suffixes can now be used to indicate measuring units (see the new constexpr keyword). Use RAII to handle resources: memory, files, sockets, hardware, operating system resources (threads, mutexes, semaphores, etc). Avoid raw pointer usage, specially in public interfaces (restrict those usages to single method implementation scope). Use smart pointers classes such as unique_ptr and shared_ptr . Don't use the latter if the resource needs to be shared. And before con

C++ 11 y su nuevo estilo, explicado por Bjarne Stroustrup

Versión en inglés / English version En una serie de charlas muy interesantes del evento GoingNative2012 organizado por Microsoft, el mísmisimo creador de C++, Bjarne Stroustrup, dio una charla sobre el nuevo estilo de programación introducido por el nuevo estándar C++ 11. El tema de la charla no son las nuevas funcionalidades del lenguaje , sino cómo usarlas correctamente; eso es lo que Bjarne denomina "estilo". A continuación, un resumen de los puntos esenciales: Type-rich interfaces: Se puede usar sufijos para indicar unidades, por ejemplo (ver la nueva keyword constexpr ). Usar RAII para recursos: memoria, archivos, sockets, hardware, recursos del sistema operativo (threads, mutexes, semáforos, etc). Evitar el uso de punteros, especialmente en interfaces (mantener esos usos acotados a implementaciones de funciones). Usar smart pointers como unique_ptr y shared_ptr . No usar este último si no se está compartiendo el recurso. Y antes de consid

Visual Studio 2010 SP1 and C++/CLI strong naming bug

Spanish version / Versión en Español This particular Visual Studio version has a bug which breaks strong naming signing for C++/CLI assemblies. Said bug is documented and has a workaround which requires editing a .Targets file. Details here . In case the link dies, I'll copy the steps below: Go to %ProgramFiles(x86)%\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32 . Open Microsoft.Cpp.Win32.targets with a text editor (this might require administrator rights). Search for <Target Name="LinkEmbedManifest" . Inside that tag, in the DelaySign attribute value, change % to $, and Link.DelaySign to LinkDelaySign (delete the period). Do the same for the KeyFile attribute (don't forget to change Link.KeyFile to LinkKeyFile).

Visual Studio 2010 SP1 y strong naming para C++/CLI

Versión en inglés / English version Este Visual tiene un bug que rompe la firma de assemblies C++/CLI con strong naming. Dicho bug está documentado y tiene una solución que requiere tocar un archivo .Targets del Visual Studio. Los detalles aquí . Por si el link se muere, copio los pasos a seguir: Ir a %ProgramFiles(x86)%\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32. Abrir Microsoft.Cpp.Win32.targets con un editor de texto (esto puede requerir derechos de administrador). Buscar el texto <Target Name="LinkEmbedManifest" . Dentro de ese tag, en el valor de la property DelaySign , cambiar % por $, y Link.DelaySign por LinkDelaySign (borrar el punto). Lo mismo para la property KeyFile (no olvidar borrar el punto para que Link.KeyFile pase a ser LinkKeyFile).