Skip to content

Instantly share code, notes, and snippets.

View Manu343726's full-sized avatar

Manu Sánchez Manu343726

View GitHub Profile
@Manu343726
Manu343726 / named_tuple.cpp
Created August 22, 2015 18:28
C++ named tuples
#include <tuple>
#include <cstdint>
#include <iostream>
namespace foonathan {
namespace string_id {
namespace detail
{
using hash_type = std::uint64_t;
@Manu343726
Manu343726 / vs-unique-config.cmake
Created September 5, 2015 11:10
Workaround to make VS behave like unique-configuration generator
# Workaround to make VS behave like unique-configuration generator:
if(WIN32 AND MSVC)
set_target_properties([TARGET]
PROPERTIES EXCLUDE_FROM_ALL TRUE)
# Build [TARGET] using CMAKE_BUILD_TYPE always, as unique-configuration makefiles
add_custom_target(build_msvc ALL
COMMAND ${CMAKE_COMMAND} --build \".\" --target [TARGET] --config ${CMAKE_BUILD_TYPE}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endif()
@Manu343726
Manu343726 / multiple_variants_run.cmake
Created September 5, 2015 21:14
Run a cmake project multiple times with multiple variants
# Custom target to do all the work with a simple command:
add_custom_target(run_all COMMAND ${CMAKE_COMMAND} -E echo \">>>> Running all variants\" WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set(common_flags "-DGENERATE_ASSEMBLY=${GENERATE_ASSEMBLY} -DCPU_MODEL=\"${CPU_MODEL}\"")
if(WIN32)
list(APPEND VARIANTS "-G \"Visual Studio 14\" -DCMAKE_BUILD_TYPE=Release")
list(APPEND VARIANTS "-G \"Visual Studio 14\" -DCMAKE_BUILD_TYPE=Debug")
list(APPEND VARIANTS "-G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release")
list(APPEND VARIANTS "-G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Debug")
@Manu343726
Manu343726 / assembly_out.cmake
Created September 5, 2015 21:33
Generating assembly listings with CMake
## Variables:
#
# OUTPUT_DIRECTORY: Directory where the assemblu file will be placed (For example "/home/manu/listings")
# ASSEMBLY_LISTING_FILE: Assembly listing filename (For example "foo.s")
# SOURCE_FILENAME: Name of the sourcefile being compiled (See bellow). For example "foo", from foo.cpp.
# TARGET: Target being compiled (Mostly an executable target). For example "foo".
if(MSVC)
# Trust me, Microsoft docs suck.
target_compile_options(${TARGET} "/Fa${OUTPUT_PATH}/${ASSEMBLY_LISTING_FILE}" /FA)
@Manu343726
Manu343726 / vs_source_groups.cmake
Last active September 18, 2015 23:27
CMake script to generate Visual Studio source groups with the same structure as the project folder hierarchy
function(_generate_vs_source_groups GROUP_NAME TOP_DIRECTORY CURRENT_SUBDIRECTORY RESULT_FILES)
file(GLOB headers
${TOP_DIRECTORY}/${CURRENT_SUBDIRECTORY}/*.h
${TOP_DIRECTORY}/${CURRENT_SUBDIRECTORY}/*.hpp
${TOP_DIRECTORY}/${CURRENT_SUBDIRECTORY}/*.hh
${TOP_DIRECTORY}/${CURRENT_SUBDIRECTORY}/*.hxx
)
@Manu343726
Manu343726 / gist:ca0ceb224ea789415387
Created September 19, 2015 18:15
Running ARM docker image with QEMU on x86_64 Arch Linux host
# Install quemu, docker, etc
yaourt -S qemu qemu-user-static binfmt-support
# The quemu-user-static AUR package is outdated and broken. The .deb package they pull is no longer in the ubuntu repository.
# Edit the PKGBUILD and use qemu-user-static_2.4+dfsg-3_amd64.deb (With SHA1 sum "84d83a16c60c82b6c579f2f750b04a3ac26c249b")
# Enable ARM emulation
update-binfmts --enable qemu-arm
#include <vector>
#include <utility>
#include <algorithm>
void update(std::vector<bool>& map, std::size_t rows, std::size_t columns, bool(*rules)(std::size_t, bool))
{
auto at = [](std::size_t row, std::size_t column)
{
return row * columns + column;
};
@Manu343726
Manu343726 / standardese.log.txt
Created May 21, 2016 21:40
Standardese output on siplasplas allocator sources
/usr/bin/cmake -H/home/manu343726/Documentos/siplasplas -B/home/manu343726/Documentos/siplasplas/build --check-build-system CMakeFiles/Makefile.cmake 0
CMake Warning (dev) at 3rdParty/cmake/boost/blocks/boost/install/install.cmake:12 (set):
Cannot set "SCOPE": current scope has no parent.
Call Stack (most recent call first):
3rdParty/cmake/boost.cmake:13 (include)
cmake/deftargets.cmake:4 (include)
CMakeLists.txt:14 (include)
This warning is for project developers. Use -Wno-dev to suppress it.
-- SIPLASPLAS THIRD PARTY LIBRARY chaiscript
@Manu343726
Manu343726 / siplasplas-reflection.log.txt
Created May 22, 2016 15:20
Standardese assertion at cpp_namespace.cpp:52 failed
[ 83%] Built target standardese-external-project
[100%] Running Standardese on siplasplas-reflection headers...
[info] Generating documentation for "/home/manu343726/Documentos/siplasplas/include/siplasplas/reflection/dynamic/entity.hpp"...
[warning] Unknown cursor kind 'UnexposedDecl'
[warning] Unknown cursor kind 'UnexposedDecl'
[info] Generating documentation for "/home/manu343726/Documentos/siplasplas/include/siplasplas/reflection/dynamic/runtime.hpp"...
[info] Generating documentation for "/home/manu343726/Documentos/siplasplas/include/siplasplas/reflection/dynamic/detail/runtime_forward.hpp"...
[info] Generating documentation for "/home/manu343726/Documentos/siplasplas/include/siplasplas/reflection/dynamic/object.hpp"...
[info] Generating documentation for "/home/manu343726/Documentos/siplasplas/include/siplasplas/reflection/dynamic/api.hpp"...
[info] Generating documentation for "/home/manu343726/Documentos/siplasplas/in
@Manu343726
Manu343726 / backward-cpp-valgrind-output.txt
Created September 9, 2016 11:54
Valgrind showing backward-cpp memory leaks when running siplasplas tests
3 FAILED TESTS
==7554==
==7554== HEAP SUMMARY:
==7554== in use at exit: 87,808 bytes in 60 blocks
==7554== total heap usage: 9,511 allocs, 9,451 frees, 1,600,428 bytes allocated
==7554==
==7554== 768 bytes in 3 blocks are definitely lost in loss record 1 of 4
==7554== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7554== by 0x4C2CF1F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7554== by 0x5A3B5B3: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22)