Skip to content

Instantly share code, notes, and snippets.

@shelvacu
Created February 6, 2026 02:41
Show Gist options
  • Select an option

  • Save shelvacu/3dff4ee8e155e4485a7b7781ba84b7b4 to your computer and use it in GitHub Desktop.

Select an option

Save shelvacu/3dff4ee8e155e4485a7b7781ba84b7b4 to your computer and use it in GitHub Desktop.
Example of gcc forward parameter declaration
// Compile with: gcc -Wall -std=gnu99 main.c
#include <stddef.h>
#include <stdlib.h>
// see https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html
void foo(size_t length; char buf[length], size_t length) {
for (size_t i=0; i<length; i++) {
buf[i] = 0;
}
}
int main(void) {
char* buf = malloc(100);
foo(buf, 128);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment