You're confusing the linkage of a pointer variable and the linkage of what it points to.
The linkage of a pointer does not change, regardless of what it points to.
Here the linkage of ptr is global (aka external) and the linkage of c is static (aka internal). Neither one changes the linkage of the other.
static means that c will not be visible (i.e. available for direct linkage) in another (e.g.) .c file. That is, another .c could not do:
int *ptr2 = &c;
But, it could do:
int **ptr3 = &ptr;
You could have the reverse:
int c = 20;
static int ptr = &c;
This is a static/internal linkage ptr pointing to a global/external linkage c.
A program has several memory areas: .text for code. .data for initialized variables (such as c) and .bss for unitialized areas.
Since you initialize both ptr and c, they both end up in .data
If you had done:
#include <stdio.h>
static int c = 20; // Static vairble
int *ptr;
int main(){
ptr = &c;
return 0;
}
Then, c is initialized and goes in .data but ptr is not initialized but is assigned and goes in the .bss segment
All variables [global or not] can have non-constant values. Either by initialization or assignment.
All above variables have global/file scope.
Here is another type of scope:
#include <stdio.h>
static int c = 20; // Static vairble
int main(){
int *ptr = &c;
return 0;
}
Here, ptr has function scope. It is placed on the stack frame of main. It has no linkage to speak of (i.e. it will never show up in the symbol table of the executable).
++*ptractually do? What indirection is occuring?