annotate lldb/test/Shell/Expr/Inputs/call-function.cpp @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 #include <iostream>
anatofuz
parents:
diff changeset
2 #include <string>
anatofuz
parents:
diff changeset
3 #include <cstring>
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 struct Five
anatofuz
parents:
diff changeset
6 {
anatofuz
parents:
diff changeset
7 int number;
anatofuz
parents:
diff changeset
8 const char *name;
anatofuz
parents:
diff changeset
9 };
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 Five
anatofuz
parents:
diff changeset
12 returnsFive()
anatofuz
parents:
diff changeset
13 {
anatofuz
parents:
diff changeset
14 Five my_five = {5, "five"};
anatofuz
parents:
diff changeset
15 return my_five;
anatofuz
parents:
diff changeset
16 }
anatofuz
parents:
diff changeset
17
anatofuz
parents:
diff changeset
18 unsigned int
anatofuz
parents:
diff changeset
19 fib(unsigned int n)
anatofuz
parents:
diff changeset
20 {
anatofuz
parents:
diff changeset
21 if (n < 2)
anatofuz
parents:
diff changeset
22 return n;
anatofuz
parents:
diff changeset
23 else
anatofuz
parents:
diff changeset
24 return fib(n - 1) + fib(n - 2);
anatofuz
parents:
diff changeset
25 }
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 int
anatofuz
parents:
diff changeset
28 add(int a, int b)
anatofuz
parents:
diff changeset
29 {
anatofuz
parents:
diff changeset
30 return a + b;
anatofuz
parents:
diff changeset
31 }
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33 bool
anatofuz
parents:
diff changeset
34 stringCompare(const char *str)
anatofuz
parents:
diff changeset
35 {
anatofuz
parents:
diff changeset
36 if (strcmp( str, "Hello world" ) == 0)
anatofuz
parents:
diff changeset
37 return true;
anatofuz
parents:
diff changeset
38 else
anatofuz
parents:
diff changeset
39 return false;
anatofuz
parents:
diff changeset
40 }
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 int main (int argc, char const *argv[])
anatofuz
parents:
diff changeset
43 {
anatofuz
parents:
diff changeset
44 std::string str = "Hello world";
anatofuz
parents:
diff changeset
45 std::cout << str << std::endl;
anatofuz
parents:
diff changeset
46 std::cout << str.c_str() << std::endl;
anatofuz
parents:
diff changeset
47 Five main_five = returnsFive();
anatofuz
parents:
diff changeset
48 #if 0
anatofuz
parents:
diff changeset
49 print str
anatofuz
parents:
diff changeset
50 print str.c_str()
anatofuz
parents:
diff changeset
51 #endif
anatofuz
parents:
diff changeset
52 return 0; // Please test these expressions while stopped at this line:
anatofuz
parents:
diff changeset
53 }