Coding practices are a source of a lot of arguments among programmers. Coding standards, to some degree, help us to put certain questions to bed and resolve stylistic debates. No coding standard makes everyone happy. (And even their existence is sure to make some unhappy.) What follows are the standards we put together on the Core team, which have become the general coding standard for all programming teams on new code development. We’ve tried to balance the need for creating a common, recognizable and readable code base with not unduly burdening the programmer with minor code formatting concerns.
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
#!/bin/bash | |
export PATH=$PATH:$HOME/x86_64-linux-musl/bin | |
export CC=x86_64-linux-musl-gcc | |
export CXX=x86_64-linux-musl-g++ | |
# wget -nc https://zlib.net/zlib-1.2.11.tar.gz | |
# wget -nc ftp://ftp-osl.osuosl.org/pub/libpng/src/libpng16/libpng-1.6.34.tar.xz | |
# wget -nc -O libjpeg.tar.gz http://sourceforge.net/project/showfiles.php?group_id=159521 | |
wget -nc https://github.com/opencv/opencv/archive/3.3.0.zip |
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
/* ... */ | |
template<size_t Dimen> | |
class NDMatrix | |
{ | |
public: | |
/* this is imaginary, as of right now: */ | |
$for(size_t i = 0; i < Dimen; ++i) { | |
/* Create one function definition for each dimen access: | |
* float &At(int x0, int x1, etc...) { return m_array[_At(...)]; } |
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
/*% cc -o # % | |
* com [-n] [file ...] | |
* looks for the sequence /*% in each file, and sends the rest of the | |
* line off to the shell, after replacing any instances of a `%' character | |
* with the filename, and any instances of `#' with the filename with its | |
* suffix removed. Used to allow information about how to compile a program | |
* to be stored with the program. The -n flag causes com not to | |
* act, but to print out the action it would have taken. | |
*/ | |
#include <string.h> |
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> | |
// #define CLANG_OR_GCC | |
// Compile with -O3 -std=c++11 for Clang version | |
#define VS | |
// Compile with -O3 -fms-compatibility -std=c++11 for VS version | |
#if defined(CLANG_OR_GCC) | |
typedef float float2 __attribute__((ext_vector_type(2))); |
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
@echo off | |
setlocal enableextensions disabledelayedexpansion | |
(for %%a in (%*) do if exist "%%~a" ( | |
pushd "%%~dpa" && ( copy /b "%%~nxa"+,, & popd ) | |
) else ( | |
type nul > "%%~fa" | |
)) >nul 2>&1 |
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
#!/bin/bash | |
export PATH=$PATH:$HOME/x86_64-linux-musl/bin | |
export CC=x86_64-linux-musl-gcc | |
export CXX=x86_64-linux-musl-g++ | |
# If needed | |
export CC="$CC -static --static" | |
export CXX="$CXX -static --static" |
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
#!/bin/bash | |
export PATH=$PATH:$HOME/x86_64-linux-musl/bin | |
export CC=x86_64-linux-musl-gcc | |
export CXX=x86_64-linux-musl-g++ | |
# If needed | |
export CC="$CC -static --static" | |
export CXX="$CXX -static --static" |
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 <string.h> | |
#include <math.h> | |
#define clamp(d, min, max) ((d) < (min) ? (min) : ((d) > (max) ? (max) : (d))) | |
float | |
sRGB_encode(float v) | |
{ |
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 <stdatomic.h> | |
#include <stdint.h> | |
#include <x86intrin.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <linux/futex.h> | |
#include <sys/time.h> | |
#include <pthread.h> | |
static uint64_t |