Declaring a function as static
makes it only availiable in its file, and compiling a program with -s
makes all the global functions and variables in it unnaccessible from outside the app. So if I just compile an app with -s
, does it have the same effect as making everything static or is it more complicated than that?
To put it in other words, would these two produce the same executable:
/*** cc -s main.c ***/
#include <stdio.h>
void a(){
printf("Hello world!\n");
}
int main(void){
a();
return 0;
}
/*** cc main.c ***/
#include <stdio.h>
static void a(){
printf("Hello world!\n");
}
int main(void){
a();
return 0;
}
The -s option when compiling does not affect the accessibility of functions and variables from outside the application. -s only strips symbols, so the executable will be a bit smaller.