Skip to content

Instantly share code, notes, and snippets.

View janwilmans's full-sized avatar
💭
Probably coding

Jan Wilmans janwilmans

💭
Probably coding
View GitHub Profile
@janwilmans
janwilmans / gist:fe0af70d083928f857ffbf138ce0a30d
Created January 30, 2017 20:32
Pack exceptions to pass them though a layer that does not support exceptions
template<typename Result, typename ...Args>
auto dzn_callee_2(std::function<Result(Args...)> fn) -> std::function<Result(std::exception_ptr context, Args...)>
{
return [=] (std::exception_ptr context, Args&&... args) mutable -> Result
{
try
{
return fn(std::forward<Args>(args)...);
}
catch (const std::exception&)
// (C) Copyright Gert-Jan de Vos and Jan Wilmans 2013.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Repository at: https://github.com/djeedjay/DebugViewPP/
#include "stdafx.h"
#include <boost/algorithm/string.hpp>
#include "CobaltFusion/scope_guard.h"
class Jan
{
  std::unique_ptr<Bar> bar;
};

class Foo
{
public:
 Foo(Bar&amp; bar) 
```c++
struct Z80
{
volatile uint8_t& memory(const uint16_t address)
{
return *reinterpret_cast<uint8_t*>(address);
}
};

C++ Coding Standards Part 0: Automated Code Analysis

Automated analysis is the main advantage to working with a modern statically typed compiled language like C++. Code analysis tools can inform us when we have implemented an operator overload with a non-canonical form, when we should have made a method const, or when the scope of a variable can be reduced.

In short, these tools catch the most commonly agreed best practice mistakes we are making and help educate us to write better code. We will be fully utilizing these tools.

Compilers

All reasonable warning levels should be enabled. Some warning levels, such as GCC's -Weffc++ warning mode can be too noisy and will not be recommended for normal compilation.

When a process causes a segmentation fault, or receives SIGSEGV (11) by default it generates a coredump file and terminates. Some libraries, for ex. (http://icanprogram.com/simpl/) install custom handlers to many signals and just calls _exit(0);

sigaction(SIGHUP, &sigact, NULL);
sigaction(SIGILL, &sigact, NULL);
sigaction(SIGABRT, &sigact, NULL);
sigaction(SIGINT, &sigact, NULL);
sigaction(SIGSEGV, &sigact, NULL);
sigaction(SIGTERM, &amp;sigact, NULL);

This blog is about how I use windows as a professional software engineer. What windows settings I customize and what tools I use to make my daily work as pleasing and productive as possible.

Performance and usability enhancements

Some of these settings are particularly well suited for virtual machines, use common sense to judge whether is it safe (enough) to turn off these features on real machines. In embedded development and hardware integration work that I do, I often find myself in situations where the network is already restricted enough by firewalls and anti-virus measures that having these options on only gets in the way.

Developer mode - Handle With Care:

  • turn off UAC (see reg file below)
  • turn off Windows Defender (see reg file below)