Skip to content

Instantly share code, notes, and snippets.

@dutc
Created June 25, 2013 17:19
Show Gist options
  • Save dutc/5860380 to your computer and use it in GitHub Desktop.
Save dutc/5860380 to your computer and use it in GitHub Desktop.
gcc -std=c99 -Wall -pedantic -o /dev/null static-qualifier.c
#include <stdlib.h>
#include <stdio.h>
void f(int x[static 3]);
void f(int x[static 3]) {
printf("%d + %d + %d = %d\n", x[0], x[1], x[2], x[0] + x[1] + x[2]);
}
int main(int argc, char* argv[]) {
int *x = malloc(sizeof(int) * 2);
x[0] = 1; x[1] = 2;
int y[2] = {1,2};
int *z = NULL;
f(x);
f(y);
f(z);
exit(EXIT_SUCCESS);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment