Skip to content

Instantly share code, notes, and snippets.


David Grayson DavidEGrayson

View GitHub Profile
DavidEGrayson / gcc-11-arm-darwin.patch
Created Jun 11, 2021
GCC 11 patch for ARM darwin
View gcc-11-arm-darwin.patch
diff -ur gcc-11.1.0/gcc/config/host-darwin.c gcc-11.1.0-fixed/gcc/config/host-darwin.c
--- gcc-11.1.0/gcc/config/host-darwin.c 2021-04-27 03:00:13.000000000 -0700
+++ gcc-11.1.0-fixed/gcc/config/host-darwin.c 2021-06-11 14:49:13.754000000 -0700
@@ -22,6 +22,10 @@
#include "coretypes.h"
#include "diagnostic-core.h"
#include "config/host-darwin.h"
+#include "hosthooks.h"
+#include "hosthooks-def.h"
View 15.c.patch
diff --git a/code/15_hello_triangle.cpp b/code/15_hello_triangle.cpp
index 532520e..31f2bd7 100644
--- a/code/15_hello_triangle.cpp
+++ b/code/15_hello_triangle.cpp
@@ -642,12 +642,15 @@ private:
void drawFrame() {
vkWaitForFences(device, 1, &inFlightFences[currentFrame], VK_TRUE, UINT64_MAX);
+ VkFence waited = inFlightFences[currentFrame];
DavidEGrayson / bad.c
Created Feb 26, 2021
Test code for Vulkan loader issues in MSYS2
View bad.c
// Compile with: gcc -g bad.c -lvulkan -lgdi32 -lglfw3
#include <vulkan/vulkan.h>
#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>
#include <string.h>
#include <stdlib.h>
DavidEGrayson /
Last active Jul 29, 2022
ffmpeg commands to extract AAC audio from an MP4, edit it, and replace it
ffprobe foo.mp4 # Make sure the audio stream is aac.
ffmpeg -i foo.mp4 -vn -acodec copy foo.aac
ffmpeg -i foo.aac -acodec pcm_s16le foo.wav
# Edit foo.wav with audacity, save to foo_edited.wav.
ffmpeg -i foo_edited.wav -acodec aac foo_edited.aac
ffmpeg -i foo.mp4 -codec copy -an foo_silent.mp4
ffmpeg -i foo_silent.mp4 -i foo_edited.aac -shortest -c:v copy -c:a aac foo_edited.mp4
# Reduce file size and remove sounds
ffmpeg -i foo.mp4 -vcodec libx264 -crf 28 -an foo_out.mp4

Building a mingw-w64 GCC cross-compiler with nixcrpkgs: instructions for Terry, October 2018

  1. Install Nix, the functional package manager. You'll need Linux (but macOS might work too).
  2. Make sure you have at least 4 GB of free space available for /tmp and a few GB of free space available for /nix.
  3. To get my recipes, run: git clone && cd nixcrpkgs && git checkout 4f7b11d That commit is the current tip of the dev/david/2019 branch.
  4. To build a i686-w64-mingw32 C/C++ cross-compiling toolchain and a hello world program, run: nix-build -A win32.hello
  5. To build Qt and its examples, run: nix-build -A win32.qt.examples
  6. To just build the toolchain itself, run: nix-build -A win32.gcc
View arch_linux_screwup.txt
[root@alderaan gradual]# pacman -Sy archlinux-keyring
:: Synchronizing package databases...
core is up to date
extra is up to date
community is up to date
warning: archlinux-keyring-20180108-1 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...
Packages (1) archlinux-keyring-20180108-1
DavidEGrayson / shell_session.txt
Last active Dec 23, 2017
AllowShortBlocksOnASingleLine is not working with clang-format 5.0.0 on Manjaro Linux
View shell_session.txt
$ clang-format --version
clang-format version 5.0.0 (tags/RELEASE_500/final)
$ cat .clang-format
AllowShortBlocksOnASingleLine: true
$ cat test.cpp
int foo(int x)
if (x == 0) { return 1; }
DavidEGrayson / does_not_compile.txt
Last active Nov 12, 2017
This code does not compile using mingw-w64 gcc in MSYS2 (and probably not in any version of gcc)
View does_not_compile.txt
$ cat somefile.h
struct a;
struct a *init();
void setd(struct a*p, int dd);
int getd(struct a*p);
void cleanup(struct a*p);
$ cat somefile.c
View msys2_path_conv_session.txt
$ cat test.c
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char ** argv)
for(int i = 0; i < argc; i ++)
printf("%d = %s\n", i, argv[i]);