Skip to content

Instantly share code, notes, and snippets.

View abel0b's full-sized avatar
🐉
Compiling

Abel Calluaud abel0b

🐉
Compiling
  • Voie lactée
View GitHub Profile
@abel0b
abel0b / snippets.mk
Created June 9, 2020 09:28
Makefile snippets
# Check if a library exists
define lib_exists
echo "int main(){}" | g++ -x c++ -Wl,--no-as-needed -l$(1) -
endef
# Update a git submodule
define update_external
if git submodule status external/$(1) | egrep -q '^[-]|^[+]'; then\
git submodule update --init external/$(1);\
fi
@abel0b
abel0b / install-llvm.sh
Created June 27, 2020 13:20
Install llvm clang openmp from sources
git clone https://github.com/llvm/llvm-project.git --depth=1 /tmp/llvm
mkdir /tmp/llvm/build
cd /tmp/llvm/build
cmake -DLLVM_ENABLE_PROJECTS="clang;openmp;libcxx;libcxxabi;libunwind;lldb;compiler-rt;lld" -DCMAKE_INSTALL_PREFIX="/opt/llvm" ../llvm
make -j64
make install
@abel0b
abel0b / dict.c
Created June 28, 2020 13:30
Simple dictionary / hash table implementation in C
#include "dict.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
static int NUMBUCKETS = 8;
static int INITBUCKETCAPACITY = 8;
void dict_new(struct Dict* dict) {
dict->numbuckets = NUMBUCKETS;
@abel0b
abel0b / appdata.c
Created November 23, 2020 19:09
Get AppData Roaming folder in C C++
// how to locate application data %AppData% directory path on Windows 10 MSVC
// see on documentation https://docs.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath?redirectedfrom=MSDN
// compiled with cl .\appdata.c Shell32.lib
#include <stdlib.h>
#include <stdio.h>
#include <shlobj_core.h>
#include <direct.h>
int main() {