Skip to content

Instantly share code, notes, and snippets.

View johnmcfarlane's full-sized avatar

John McFarlane johnmcfarlane

View GitHub Profile
@johnmcfarlane
johnmcfarlane / What compiler and language is this?.cpp
Created May 2, 2020 10:02
Script for printing compiler version and language revision as a diagnostic
template <int c, long s> struct _;
#if defined(__clang__)
_<__clang_major__, __cplusplus> clang_version_and_standard;
#elif defined(__GNUC__)
_<__GNUC__, __cplusplus> gcc_version_and_standard;
#elif defined(_MSC_VER)
_<_MSC_VER, __cplusplus> msvc_version_and_standard;
#else
#error "I don't know that compiler"
#endif
@johnmcfarlane
johnmcfarlane / integer-3770d0.cpp
Last active April 18, 2020 12:38
Preprocessed source, /tmp/integer-3770d0.cpp, associated with clang frontend crash
This file has been truncated, but you can view the full file.
# 1 "<built-in>"
# 1 "/home/john/ws/rounding-overflow/cnl/test/unit/scaled_integer/rounding/elastic/integer.cpp"
// Copyright John McFarlane 2015 - 2016.
// 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)
#if 0 /* expanded by -frewrite-includes */
#include <cnl/elastic_integer.h>
@johnmcfarlane
johnmcfarlane / msan-build.sh
Created February 14, 2020 21:58
Script for building MSan
set -exu pipeline
SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
PROJECT_DIR="$SCRIPT_DIR"/llvm-project
mkdir -p build
cd build
cmake \
-GNinja \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
@johnmcfarlane
johnmcfarlane / wwf_lexicon.cpp
Created December 9, 2019 08:07
Scrabble-like lexicon hard-coded in C++ as a DAWG
This file has been truncated, but you can view the full file.
#include "wwf_lexicon.h"
namespace {
node nAAHED = {
"",
nullptr,
true
};
node nAAHEe[] {nAAHED};
node nAAHE = {
"D",
@johnmcfarlane
johnmcfarlane / pre-cologne numeric TS thoughts.md
Last active July 13, 2019 16:20
Response to inquiry by WG21/LEWG-I chair about the state of the Numeric TS

Where I Think We Are With a Numeric TS

  • This is in answer to Bryce's question about how we should be working towards a Numeric TS.
  • It's my (John McF's) frank and personal opinion about the bits I care about.
  • Written a day before the Cologne 2019 meeting.

Current situation

I interpreted from Kona LEWG-I minutes that we're still exploring the design space. Specific work done by me for Cologne:

@johnmcfarlane
johnmcfarlane / preprocessor_killjoy.h
Created May 22, 2019 13:30
What happened when I added preprocessor_fun.h to a modern, tooled-up C++ project.
// Out of curiosity I took preprocessor_fun.h
// https://gist.github.com/aras-p/6224951
// and added it to a project at work to see what happens when random C
// preprocessor hacks are applied to a modern C++ project with CI.
// Unfortunately, about half were flagged as warnings/errors by the compiler.
// Almost all of the rest had no effect because the codebase uses too much
// of the Standard Library / just doesn't use those APIs.
// The only one which wasn't caught by static tools was __builtin_expect
// which showed up as a failed death test. It is used in <gsl/gsl_assert> so
// should cause a decent amount of consternation in GSL-dependent projects.
// Copyright John McFarlane 2018.
// 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)
// mechanically retrieved, single-header version of CNL library
// https://github.com/johnmcfarlane/cnl
#if ! defined(CNL_COMPLETE_H)
@johnmcfarlane
johnmcfarlane / DoxyPress-installation-woes.md
Created April 22, 2019 11:22
Some observations about one attempt to install DoxyPress on Linux

Tested on Ubuntu 18.10

  1. Cloned copperspice/doxypress

  2. README has no instructions on how to build and instead sends me to DoxyPress docs: https://www.copperspice.com/docs/doxypress/build-doxypress.html

    • Six major dependencies are presented

      • They don't differentiate between DoxyPress and DoxyPressApp
  • #5 claims that I need automake or CMake. This doesn't appear to be the case (*).
@johnmcfarlane
johnmcfarlane / cnl2.h
Created April 17, 2019 21:57
number<> & pals
#include <functional>
#include <type_traits>
#include <utility>
namespace cnl2 {
////////////////////////////////////////////////////////////////////////////////
// Arithmetic - is a something that supports arithmetic operators
//
// As well as a fundamental arithmetic type (unsigned short int, __int128, etc.)
// a class-based type (a pack<> or a number<> instantiation) although bool is
@johnmcfarlane
johnmcfarlane / cnl_complete_17_128bit.h
Last active May 13, 2019 00:22
Single-header CNL library for C++17 with 128-bit integer support
// Copyright John McFarlane 2018.
// 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)
// mechanically retrieved, single-header version of CNL library
// https://github.com/johnmcfarlane/cnl
#if ! defined(CNL_COMPLETE_H)