mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Research: Learn about the function call
This commit is contained in:
parent
a060befebf
commit
a7961e558b
2 changed files with 56 additions and 0 deletions
22
trunk/research/frame/frame0.cpp
Normal file
22
trunk/research/frame/frame0.cpp
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
/*
|
||||||
|
g++ frame0.cpp -g -O0 -o frame && ./frame
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int callee(int a, long b) {
|
||||||
|
int c = a;
|
||||||
|
c += (int)b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
void caller() {
|
||||||
|
int v = callee(10, 20);
|
||||||
|
printf("v=%d\n", v);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
caller();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
34
trunk/research/frame/frame1.cpp
Normal file
34
trunk/research/frame/frame1.cpp
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
g++ frame1.cpp -g -O0 -o frame && ./frame
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int callee(int a, long b, long c, int d, long e, int f, int g, int h) {
|
||||||
|
int v = a;
|
||||||
|
v += (int)b;
|
||||||
|
v += (int)c;
|
||||||
|
v += (int)e;
|
||||||
|
v += (int)g;
|
||||||
|
v += (int)h;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
void caller() {
|
||||||
|
int a = 10;
|
||||||
|
int b = 20;
|
||||||
|
long c = 30;
|
||||||
|
int d = 40;
|
||||||
|
int e = 50;
|
||||||
|
int f = 60;
|
||||||
|
int g = 70;
|
||||||
|
int h = 80;
|
||||||
|
int v = callee(a, b, c, d, e, f, g, h);
|
||||||
|
printf("v=%d, c=%ld\n", v, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
caller();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue