Skip to content

Instantly share code, notes, and snippets.

GavinRay97 / extensions.json
Created Jun 7, 2021
VS Code "clangd" base config, with: CMake Tools extension, MS C/C++ extension (debugging), vcpkg integration
View extensions.json
"recommendations": [
GavinRay97 / Makefile
Last active May 23, 2021
Dump C/C++ vtable & record layout information (clang + msvc)
View Makefile
# Requirements:
# clang - The classes/structs you want to dump must be used in code at least once, not just defined.
# MSVC - The classes/structs you want to dump must have "MEOW" in the name for "reportSingleClass" to work.
# Usage:
# $ make dump_vtables file=test.cpp
clang -cc1 -fdump-record-layouts -emit-llvm $(file) > clang-vtable-layout-$(file).txt
clang -cc1 -fdump-vtable-layouts -emit-llvm $(file) > clang-record-layout-$(file).txt
cl.exe $(file) /d1reportSingleClassLayoutMEOW > msvc-single-class-vtable-layout-$(file).txt
cl.exe $(file) /d1reportAllClassLayout > msvc-all-class-vtable-layout-$(file).txt
GavinRay97 / main.d
Created May 14, 2021
D-lang Multiple Inheritance mimickry
View main.d
import std.stdio;
interface Abstract1 {
void overrideMe1();
void sayHello();
mixin template Abstract1Impl() {
void sayHello() { import std.stdio; writeln("Hello"); }
GavinRay97 /
Last active May 5, 2021
JUCE clang-format using whatstyle


I chose to run on juce_VST3_Wrapper.cpp because of the headers and cpp files in the project, it was one of the largest. Note that the BinaryData files actually contain binary data, and that WindowedSincInterpolator.cpp contains massive data arrays that take up space.

In an ideal scenario, I would run this on an amalgamted JUCE build of all the files in the project using:

(I have this already and may run this again on that file)

GavinRay97 /
Created May 1, 2021
Get Clang builtin macro/preprocessor definitions from the compiler
# Works in both Windows + Linux/Mac
# For standard clang
echo | clang -dM -E -
# For clang-cl.exe
echo | clang -fms-extensions -dM -E -
View main.d
struct Assumer(T, alias assumeThis)
T store;
pragma(inline, true)
T get()
import gcc.builtins;
return store;
GavinRay97 / juce_audio_plugin_client_amalgamated.h
Created Apr 11, 2021
JUCE amalgamated audio plugin headers
View juce_audio_plugin_client_amalgamated.h
This file has been truncated, but you can view the full file.
This file is part of the JUCE library.
Copyright (c) 2020 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
GavinRay97 / jsfx_dotprod.c
Created Mar 15, 2021 — forked from ess7/jsfx_dotprod.c
JSFX extension: dot product
View jsfx_dotprod.c
// params: y0, y1, interleaved x, coeff, n
static EEL_F NSEEL_CGEN_CALL dotprod2(void *opaque, INT_PTR np, EEL_F **parms) {
EEL_F **blocks = (EEL_F **)opaque;
int xofs = *parms[2];
int cofs = *parms[3];
int n = *parms[4];
*parms[0] = 0.0;
*parms[1] = 0.0;
if (unlikely(n <= 0 || xofs < 0 || cofs < 0 ||
GavinRay97 / settings.json5
Created Mar 9, 2021
VS Code official C/C++ Extension combined with clangd
View settings.json5
// From:
"C_Cpp.intelliSenseEngine": "Disabled",
"C_Cpp.autocomplete": "Disabled", // So you don't get autocomplete from both extensions.
"C_Cpp.errorSquiggles": "Disabled", // So you don't get error squiggles from both extensions (clangd's seem to be more reliable anyway).
"clangd.path": "/path/to/your/clangd",
"clangd.arguments": ["-log=verbose", "-pretty", "--background-index", "--compile-commands-dir=/path/to/your/compile_commands_dir/"]
GavinRay97 / omnisharp.json
Created Mar 3, 2021
C# - Omnisharp settings for not-fucked-up, terrible, awful formatting (IE like JS/TS/Java/Swift/literally every other C-based language)
View omnisharp.json
"FormattingOptions": {
"NewLinesForBracesInLambdaExpressionBody": false,
"NewLinesForBracesInAnonymousMethods": false,
"NewLinesForBracesInAnonymousTypes": false,
"NewLinesForBracesInControlBlocks": false,
"NewLinesForBracesInTypes": false,
"NewLinesForBracesInMethods": false,
"NewLinesForBracesInProperties": false,
"NewLinesForBracesInAccessors": false,