Skip to content

Instantly share code, notes, and snippets.

@tobin
Last active May 9, 2017 00:42
Show Gist options
  • Save tobin/71d93201d09974c7a72c3fbb13dcd4bd to your computer and use it in GitHub Desktop.
Save tobin/71d93201d09974c7a72c3fbb13dcd4bd to your computer and use it in GitHub Desktop.
static const
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
const int baz = rand(); // ok!
baz = 99; // compile-time error.
static int goo = rand(); // compile-time error.
goo = 99; // ok.
// So if we want a local variable to be "really constant," we really
// do want to use "static const":
static const int foo = 22; // ok.
static const int bar = rand(); // compile-time error.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment