const
can be applied to type specifier (or base type).const
can be applied to pointer.const
, depends on where it's placed, forbids you to do assignment.
const int *p = &x; // or int const *p = &x;
""" | |
{ | |
"type": "sub" | "unsub", | |
"fields": [ "all" | <one or more field_list separated by ,> ] | |
} | |
field_list: | |
- "magnitudo" | |
- "depth" | |
- "location" |
// DFS Tree traversal | |
// I always forgot about this even though they are simple | |
// For use in AST, post-order is used | |
#include <assert.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
struct Node { | |
struct Node *left; |
// Operator Associativity Description | |
// -------- ------------- ----------- | |
// x! right to left Factorial | |
// +x -x ~x !x right to left Positive, negative, bitwise NOT, logical NOT | |
// * / % left to right Multiplication, division, modulo | |
// + - left to right Addition, subtraction | |
// << >> left to right Bitwise shifts | |
// & left to right Bitwise AND | |
// ^ left to right Bitwise XOR | |
// | left to right Bitwise OR |
#ifndef MY_CTYPE_H | |
#define MY_CTYPE_H | |
#define U_ 0x01 | |
#define L_ 0x02 | |
#define D_ 0x04 | |
#define S_ 0x08 | |
#define P_ 0x10 | |
#define X_ 0x20 | |
#define C_ 0x40 |
#if defined(__GNUC__) || defined(__clang__) | |
#pragma GCC poison strncpy | |
#endif | |
#include <stdio.h> | |
#include <string.h> | |
int main(void) | |
{ | |
char buf[20]; |
print("/**\n * Branchless <ctype.h> replacement") | |
print(" *\n * GENERATED BY tools/gen.py, DO NOT EDIT!\n */\n") | |
print("#ifndef BRANCHLESS_CTYPE_H") | |
print("#define BRANCHLESS_CTYPE_H\n") | |
print("#include <stdint.h>\n") | |
print("#define is_alnum(c) (alnum_tab[(uint8_t)(c)])") | |
print("#define is_alpha(c) (alpha_tab[(uint8_t)(c)])") |
#include <assert.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define unlikely(x) (__builtin_expect(!!(x), 0)) | |
#ifndef N | |
#define N 1000000 | |
#endif |
#include <stdio.h> | |
#include <stdint.h> | |
#include <string.h> | |
static uint32_t hexstr_to_u32(const char *str) | |
{ | |
uint32_t hex = 0; | |
for (uint32_t i = 0; i < 4; i++) { | |
if (str[i] >= '0' && str[i] <= '9') |
#include <stdlib.h> | |
#include <string.h> | |
static char *astrncpy__(char **dst, const char *src, size_t size, int check) | |
{ | |
if (dst == NULL) { | |
return NULL; | |
} else if (src == NULL) { | |
*dst = NULL; | |
return NULL; |