1
submitted 3 years ago* (last edited 3 years ago) by pizza_is_yum@slrpnk.net to c/c_programming@lemmy.ml

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 new old
there doesn't seem to be anything here
this post was submitted on 04 Aug 2022
1 points (100.0% liked)

The C Programming Language

766 readers
4 users here now

Everything related to the C programming language.

founded 6 years ago