This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO: Add options for library generation. | |
# Even though this makefile is only intended as testing purpose, I'm not entirely happy with it. | |
# Indeed, I got multiple evals, and a more or less serious problem : | |
# the makefile has no "memory", so it does not remember the previous build config. | |
# The problem is, if we build in a debug mod, and then in a release mod, nothing will be rebuilt. | |
# To build with another mod, we need to clean the whole obj files, and then build with the desired config. | |
# One possible fix would be, instead of using target dependent variables for "debug", "release" and "analysis" | |
# rules, using the $@ automatic variable (name of the target) along with secondary expansion (.SECONDARYEXPANSION:) | |
# to build the dependency list. This way, to object files would be separated. We would have obj/debug for debug objs, | |
# and obj/release for release objs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Damn is this makefile ugly ! And buggy tooo ! | |
# But it was sure fun to write :P | |
# The shell that the make will use to execute shell commands. | |
# It can be set to any decent shell without any problem. | |
SHELL:=/bin/bash | |
# We only define the C++ compiler, and it will take care of compiling both C and C++ files. | |
# We also set the linker (LD) to the same value, as most of the compilers do it through the same command. | |
CXX= clang++ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This makefile has basically the same goal as the previous ones, but do a greater job. | |
# Bugs the others had are now fixed ! The compilation for a configuration will not require | |
# cleaning objs to produce its result. | |
# PROS : -Easy to use, drop in makefile | |
# -Quite configurable on its own | |
# -Manages release and debug mod automatically | |
# -Supports mix of C and C++ files without further configuration | |
# CONS : -Bad extensibility | |
# -Using a sub makefile, so less compact than the previous ones | |
# -Target dependent variables were not the great idea I thought it would be |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This makefile is geared towards begginers and people who want fast prototyping and/or testing, | |
# and even if not willing to take the time to write a makefile, wants to have a configurable and yet | |
# solid solution. | |
# So yes, this makefile is general purpose, but really only useful for small to average projects. | |
# Indeed, bigger projects will require build mecanism far more advanced than such a simple makefile | |
# (or beware of everlasting compilation time ...). | |
# So, even if this makefile should be more than enough in general, there's few caveheats you should | |
# be aware of. | |
# First of all, to save typing and hassle, this makefile do a bunch of things "automagically". This, of course, | |
# includes some overhead (but usually not that much). So if you want really fast iteration time, this may be not |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <File.hxx> | |
File::File(const std::string& pathName, const char* openMode) : fileInfos_(initPath(pathName)), | |
filePtr_(nullptr), | |
openMode_(openMode) | |
{ | |
init(); | |
} | |
File::File(std::string&& pathName, const char* openMode) : fileInfos_(initPath(std::move(pathName))), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We will assume for all the following examples that x > 0 (IMPORTANT !) | |
This little formula will determine if the number is power of two : | |
(x & -x) == x | |
How does it works ? | |
First, let's try to formulate what it means in english : | |
The only bits that x and -x have set to 1 in common, are the bits | |
set to 1 in x. | |
In fact, it's based on a simple observation. Let examine the number 4 : | |
4 = 00000100b | |
-4 = ~00000100b + 1b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdint> | |
int64_t number = 0; | |
int main() | |
{ | |
while(true) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <AsyncFileReader.hxx> | |
AsyncFileReader::~AsyncFileReader() | |
{ | |
if(th_.joinable()) | |
{ | |
th_.join(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <map> | |
#include <iostream> | |
#include <string> | |
#include <utility> | |
// A very simple logging system, shamelessly inspired by : | |
// https://github.com/CppCon/CppCon2014/blob/master/Lightning%20Talks/Cheap,%20Simple,%20and%20Safe%20Logging%20Using%20Expression%20Templates/Cheap,%20Simple,%20and%20Safe%20Logging%20Using%20Expression%20Templates%20-%20Marc%20Eaddy.pdf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stddef.h> | |
#include <stdint.h> | |
// DISCLAIMER : Before telling me that the results are wrong, read the text below ! | |
// This code is a "demonstration" of the desastrous effects of undefined behaviour in the particular case of strict-aliasing rule breaking | |
// (even if undefined behaviours are always bad of course). | |
// The results were produced using gcc 5.2.0, with and without optimizations (precised when it differs). So, the results migh change depending |