this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

static_assert from c11

Nesbox 3ac7a66b 6c0485e9

+26 -20
+1 -1
CMakeLists.txt
··· 124 124 125 125 else() 126 126 127 - set(CMAKE_C_STANDARD 99) 127 + set(CMAKE_C_STANDARD 11) 128 128 endif() 129 129 130 130 set(THIRDPARTY_DIR ${CMAKE_SOURCE_DIR}/vendor)
+2 -1
src/cart.c
··· 29 29 30 30 #include <string.h> 31 31 #include <stdlib.h> 32 + #include <assert.h> 32 33 33 34 typedef enum 34 35 { ··· 61 62 u32 temp:8; 62 63 } Chunk; 63 64 64 - STATIC_ASSERT(tic_chunk_size, sizeof(Chunk) == 4); 65 + static_assert(sizeof(Chunk) == 4, "tic_chunk_size"); 65 66 66 67 static const u8 Sweetie16[] = {0x1a, 0x1c, 0x2c, 0x5d, 0x27, 0x5d, 0xb1, 0x3e, 0x53, 0xef, 0x7d, 0x57, 0xff, 0xcd, 0x75, 0xa7, 0xf0, 0x70, 0x38, 0xb7, 0x64, 0x25, 0x71, 0x79, 0x29, 0x36, 0x6f, 0x3b, 0x5d, 0xc9, 0x41, 0xa6, 0xf6, 0x73, 0xef, 0xf7, 0xf4, 0xf4, 0xf4, 0x94, 0xb0, 0xc2, 0x56, 0x6c, 0x86, 0x33, 0x3c, 0x57}; 67 68 static const u8 Waveforms[] = {0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe, 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe};
+5 -4
src/core/core.c
··· 31 31 #include <ctype.h> 32 32 #include <stddef.h> 33 33 #include <time.h> 34 + #include <assert.h> 34 35 35 36 #ifdef _3DS 36 37 #include <3ds.h> 37 38 #endif 38 39 39 - STATIC_ASSERT(tic_bank_bits, TIC_BANK_BITS == 3); 40 - STATIC_ASSERT(tic_map, sizeof(tic_map) < 1024 * 32); 41 - STATIC_ASSERT(tic_vram, sizeof(tic_vram) == TIC_VRAM_SIZE); 42 - STATIC_ASSERT(tic_ram, sizeof(tic_ram) == TIC_RAM_SIZE); 40 + static_assert(TIC_BANK_BITS == 3, "tic_bank_bits"); 41 + static_assert(sizeof(tic_map) < 1024 * 32, "tic_map"); 42 + static_assert(sizeof(tic_vram) == TIC_VRAM_SIZE, "tic_vram"); 43 + static_assert(sizeof(tic_ram) == TIC_RAM_SIZE, "tic_ram"); 43 44 44 45 static inline u32* getOvrAddr(tic_mem* tic, s32 x, s32 y) 45 46 {
+3 -1
src/core/io.c
··· 23 23 #include "api.h" 24 24 #include "core.h" 25 25 26 - STATIC_ASSERT(tic80_input, sizeof(tic80_input) == 12); 26 + #include <assert.h> 27 + 28 + static_assert(sizeof(tic80_input) == 12, "tic80_input"); 27 29 28 30 static bool isKeyPressed(const tic80_keyboard* input, tic_key key) 29 31 {
+9 -8
src/core/sound.c
··· 25 25 #include "core.h" 26 26 27 27 #include <string.h> 28 + #include <assert.h> 28 29 29 30 #define ENVELOPE_FREQ_SCALE 2 30 31 #define SECONDS_PER_MINUTE 60 ··· 32 33 #define PIANO_START 8 33 34 34 35 static const u16 NoteFreqs[] = { 0x10, 0x11, 0x12, 0x13, 0x15, 0x16, 0x17, 0x18, 0x1a, 0x1c, 0x1d, 0x1f, 0x21, 0x23, 0x25, 0x27, 0x29, 0x2c, 0x2e, 0x31, 0x34, 0x37, 0x3a, 0x3e, 0x41, 0x45, 0x49, 0x4e, 0x52, 0x57, 0x5c, 0x62, 0x68, 0x6e, 0x75, 0x7b, 0x83, 0x8b, 0x93, 0x9c, 0xa5, 0xaf, 0xb9, 0xc4, 0xd0, 0xdc, 0xe9, 0xf7, 0x106, 0x115, 0x126, 0x137, 0x14a, 0x15d, 0x172, 0x188, 0x19f, 0x1b8, 0x1d2, 0x1ee, 0x20b, 0x22a, 0x24b, 0x26e, 0x293, 0x2ba, 0x2e4, 0x310, 0x33f, 0x370, 0x3a4, 0x3dc, 0x417, 0x455, 0x497, 0x4dd, 0x527, 0x575, 0x5c8, 0x620, 0x67d, 0x6e0, 0x749, 0x7b8, 0x82d, 0x8a9, 0x92d, 0x9b9, 0xa4d, 0xaea, 0xb90, 0xc40, 0xcfa, 0xdc0, 0xe91, 0xf6f, 0x105a, 0x1153, 0x125b, 0x1372, 0x149a, 0x15d4, 0x1720, 0x1880 }; 35 - STATIC_ASSERT(count_of_freqs, COUNT_OF(NoteFreqs) == NOTES * OCTAVES + PIANO_START); 36 - STATIC_ASSERT(tic_sound_register, sizeof(tic_sound_register) == 16 + 2); 37 - STATIC_ASSERT(tic_sample, sizeof(tic_sample) == 66); 38 - STATIC_ASSERT(tic_track_pattern, sizeof(tic_track_pattern) == 3 * MUSIC_PATTERN_ROWS); 39 - STATIC_ASSERT(tic_track, sizeof(tic_track) == 3 * MUSIC_FRAMES + 3); 40 - STATIC_ASSERT(tic_music_cmd_count, tic_music_cmd_count == 1 << MUSIC_CMD_BITS); 41 - STATIC_ASSERT(tic_music_state_size, sizeof(tic_music_state) == 4); 36 + static_assert(COUNT_OF(NoteFreqs) == NOTES * OCTAVES + PIANO_START, "count_of_freqs"); 37 + static_assert(sizeof(tic_sound_register) == 16 + 2, "tic_sound_register"); 38 + static_assert(sizeof(tic_sample) == 66, "tic_sample"); 39 + static_assert(sizeof(tic_track_pattern) == 3 * MUSIC_PATTERN_ROWS, "tic_track_pattern"); 40 + static_assert(sizeof(tic_track) == 3 * MUSIC_FRAMES + 3, "tic_track"); 41 + static_assert(tic_music_cmd_count == 1 << MUSIC_CMD_BITS, "tic_music_cmd_count"); 42 + static_assert(sizeof(tic_music_state) == 4, "tic_music_state_size"); 42 43 43 44 static s32 getTempo(tic_core* core, const tic_track* track) 44 45 { ··· 422 423 if (cmdData->vibrato.period && cmdData->vibrato.depth) 423 424 { 424 425 static const s32 VibData[] = { 0x0, 0x31f1, 0x61f8, 0x8e3a, 0xb505, 0xd4db, 0xec83, 0xfb15, 0x10000, 0xfb15, 0xec83, 0xd4db, 0xb505, 0x8e3a, 0x61f8, 0x31f1, 0x0, 0xffffce0f, 0xffff9e08, 0xffff71c6, 0xffff4afb, 0xffff2b25, 0xffff137d, 0xffff04eb, 0xffff0000, 0xffff04eb, 0xffff137d, 0xffff2b25, 0xffff4afb, 0xffff71c6, 0xffff9e08, 0xffffce0f }; 425 - STATIC_ASSERT(VibData, COUNT_OF(VibData) == 32); 426 + static_assert(COUNT_OF(VibData) == 32, "VibData"); 426 427 427 428 s32 p = cmdData->vibrato.period << 1; 428 429 pitch += (VibData[(cmdData->vibrato.tick % p) * COUNT_OF(VibData) / p] * cmdData->vibrato.depth) >> 16;
-1
src/defines.h
··· 23 23 #pragma once 24 24 25 25 #define COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) 26 - #define STATIC_ASSERT(name, condition) typedef char static_assert_dummy_ ## name[(condition) ? 1 : -1] 27 26 #define MIN(a,b) ((a) < (b) ? (a) : (b)) 28 27 #define MAX(a,b) ((a) > (b) ? (a) : (b)) 29 28 #define CLAMP(v,a,b) (MIN(MAX(v,a),b))
+2 -1
src/ext/png.c
··· 26 26 #include <string.h> 27 27 #include <stdlib.h> 28 28 #include <png.h> 29 + #include <assert.h> 29 30 30 31 #define RGBA_SIZE sizeof(u32) 31 32 ··· 167 168 u8 data[RGBA_SIZE]; 168 169 } Header; 169 170 170 - STATIC_ASSERT(header_size, sizeof(Header) == RGBA_SIZE); 171 + static_assert(sizeof(Header) == RGBA_SIZE, "header_size"); 171 172 172 173 #define BITS_IN_BYTE 8 173 174 #define HEADER_BITS 4
+2 -1
src/studio/editors/code.c
··· 24 24 #include "ext/history.h" 25 25 26 26 #include <ctype.h> 27 + #include <assert.h> 27 28 28 29 #define TEXT_CURSOR_DELAY (TIC80_FRAMERATE / 2) 29 30 #define TEXT_CURSOR_BLINK_PERIOD TIC80_FRAMERATE ··· 34 35 35 36 typedef struct CodeState CodeState; 36 37 37 - STATIC_ASSERT(CodeStateSize, sizeof(CodeState) == sizeof(u8)); 38 + static_assert(sizeof(CodeState) == sizeof(u8), "CodeStateSize"); 38 39 39 40 enum 40 41 {
+2 -2
src/studio/screens/console.c
··· 815 815 static const char* Sections[] = 816 816 { 817 817 "code", 818 - #define SECTION_DEF(name, ...) #name, 818 + #define SECTION_DEF(name, ...) #name, 819 819 TIC_SYNC_LIST(SECTION_DEF) 820 - #undef SECTION_DEF 820 + #undef SECTION_DEF 821 821 }; 822 822 823 823 bool found = false;