miniblog.

← Back to all posts
42
Today in cursed C code: void foo(int32_t int32_t, int32_t bar); Since C puts identifiers and typedefs in the same namespace, this code just produces a confusing compile error about the type of bar! (This occurred in some real code after macro expansion.)

2 Comments

@wilfredh I ran into this when I accidentally made name resolution in ObjC method signatures consistent with that rule. It turns out a lot of people have methods like `-foo:(int)id bar:(id)obj` and (reasonably?) expect id to be a type…
@wilfredh At first I was like "why would the first param be in scope for the second", but I guess C VLAs mean that syntax like void process_matrix(int rows, int cols, int matrix[rows][cols]) is legal, so I guess it makes some sense? It's also a little bit interesting that it maybe is processed left to right (e.g. rows can't be last param), while meanwhile on the calling side (at runtime, so not a very nearby concept) the order of evaluation of function parameters is undefined.