this post was submitted on 04 Aug 2022
1 points (100.0% liked)

The C Programming Language

32 readers
6 users here now

Everything related to the C programming language.

founded 5 years ago
MODERATORS
 

Let's say I have two arrays that have related data:

const char *backend_short[] = { "oal", "pa", "sdl_m" };
const char *backend_long[] = { "openal", "portaudio", "sdl_mixer" };

Does C support a way to "assert" that these two arrays have the same size? And failing compilation if they are different? I want a safeguard in case I'm drunk one day and forget to keep these synchronized.

Thanks in advance.

EDIT: I found a solution. Here are some enlightening resources on the matter:

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here