Skip to content

Instantly share code, notes, and snippets.

View mlabbe's full-sized avatar

Michael Labbe mlabbe

View GitHub Profile

I was told by @mmozeiko that Address Sanitizer (ASAN) works on Windows now. I'd tried it a few years ago with no luck, so this was exciting news to hear.

It was a pretty smooth experience, but with a few gotchas I wanted to document.

First, download and run the LLVM installer for Windows: https://llvm.org/builds/

Then download and install the VS extension if you're a Visual Studio 2017 user like I am.

It's now very easy to use Clang to build your existing MSVC projects since there's a cl compatible frontend:

@mlabbe
mlabbe / ftg_core.h
Last active December 4, 2021 00:26
/* clang-format off */
/* ftg_core.h - v0.6 - Frogtoss Toolbox. Public domain-like license below.
ftg libraries are copyright (C) 2015-2021 Frogtoss Games, Inc.
http://github.com/mlabbe/ftg_toolbox
ftg header files are single file header files intended to be useful
in C/C++. ftg_core contains generally useful functions
Special thanks to STB for the inspiration.
// assume sequential consistency.
// this technique prevents frequent synchronization (cache line thrashing) of the read/write positions
// in the case where the ring buffer is running neither too close to full or too close to empty. it
// relies on the fact that an out of date notion of the read/write positions are conservative approximations.
// globals in shared memory. assume in different cache lines to prevent false sharing.
int read_pos, write_pos;
// reader
@mlabbe
mlabbe / static.h
Created April 9, 2016 05:27
C89 static assert
// usage: FTG_STATIC_ASSERT(1==0)
// error message contains "assertion_at_line_xxx"
//
// usage: FTG_STATIC_ASSERT_MSG(1==0, one_is_not_zero)
// error message contains: "one_is_not_zero"
//
// tested on GCC, Clang, MSVC 98 and MSVC 2015
//
@tomnomnom
tomnomnom / json-parsing.go
Created October 27, 2013 10:49
Parsing arbitrary JSON with go
package main
import (
"log"
"fmt"
"encoding/json"
)
func main() {
b := []byte(`{"name": "tom", "favNum": 6, "interests": ["knives", "computers"], "usernames": {"github": "TomNomNom", "twitter": "@TomNomNom"}}`)