C
chnorik
I wonder whether it is a standard behaviour for any c compiler:
noch@localhost:~$ cat test2.c
#include <stdio.h>
int miban(){
printf ("aaa\n");
}
noch@localhost:~$ cat test.c
int main(){
miban();
return 0;
}
noch@localhost:~$ cc -c test2.c
noch@localhost:~$ cc -c test.c
noch@localhost:~$ cc -o test test.o test2.o
noch@localhost:~$ ./test
aaa
What I mean, is that I didn't use header file in order to export
miban() from second module.
But... in assembly it is possible to mark symbol to be visible from
outside. I mean, object files support incapsulation concept.
What I see in generated assembly from second module is that miban()
function is marked as .globl
..globl miban
.type miban, @function
This means, that in principle, anyone without inreface specs will be
able to use private functions.
And I want to use this possibility in my codegenerator, because I do
not want to generate header files, they are not necessary for that
custom task
What I want to know is how portable this solution is, i. e. will it
work with _any_ c compiler out there?
noch@localhost:~$ cat test2.c
#include <stdio.h>
int miban(){
printf ("aaa\n");
}
noch@localhost:~$ cat test.c
int main(){
miban();
return 0;
}
noch@localhost:~$ cc -c test2.c
noch@localhost:~$ cc -c test.c
noch@localhost:~$ cc -o test test.o test2.o
noch@localhost:~$ ./test
aaa
What I mean, is that I didn't use header file in order to export
miban() from second module.
But... in assembly it is possible to mark symbol to be visible from
outside. I mean, object files support incapsulation concept.
What I see in generated assembly from second module is that miban()
function is marked as .globl
..globl miban
.type miban, @function
This means, that in principle, anyone without inreface specs will be
able to use private functions.
And I want to use this possibility in my codegenerator, because I do
not want to generate header files, they are not necessary for that
custom task
What I want to know is how portable this solution is, i. e. will it
work with _any_ c compiler out there?