summaryrefslogtreecommitdiffstats
path: root/languages/cpp/debugger/tests/print_pointers/print_pointers.cpp
blob: 09053b51b0fd57a26fba2944edbed1edd7a528dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

#include <qstring.h>
#include <vector>

struct B { int i; int j; static int k; };
struct C { int a[3]; };
struct D { int *ptr; };
int B::k = 11;
typedef int (*fp)(int);

int g = 10;
int g2 = 23;

void func2()
{
    int foobar = 123;
    printf("func2\n");
}

void func(QString& xs)
{
   int ac = 10;	
   std::string s;
   func2();
   g = 10;
   xs = "foo";
   
}

class Test
{
 public:
     QString n;
     int b;
};

int test_main(int ac, char* av[])
{
    printf("Hello world\n");
    int i = 10;
    int* p1 = 0x00000000;
    int** p1_p = &p1;
    p1 = &g;    

    B* p2 = (B*)0x12345678;
    g = 77;
    int (*p3)(int) = (fp)0x000000AE;
    B p4 = {1, 3};
    p2 = &p4;
    int p5[] = {5, 6, 7};
    int* p6[] = {&g, &g2};
    int p7[][2] = {{1,2}, {5,6}};
    B p8[] = {{1,2}, {3,4}};
    C p9 = {{7, 8, 9}};
    g = 77;
    const D p9_1 = {&g};
    {
        B p9_1;        
        int i = 15;
        printf("p9_1\n");
    }
    B& p10 = p4;
    int& p11 = *p1;
    int (*p12)[3] = &p5;
    int (&p13)[3] = p5;
    char p14[6] = "abc";
    wchar_t* p15 = L"test1"; 

 
    QString s = "test test test test";
    QString* sp = &s;
    const QString& sr = s;
    func(s);
    i = 15;
    
    std::vector<int> v;
    
    Test* test = new Test;
    Test& test2 = *test;
    test->n = "foo";
    printf("hi\n");
    test = 0;
    printf("hi2\n");
    printf("hi %d\n", test->b);
    
    
    
    p5[1] = 14;
    return 0;
}

int main(int ac, char* av[])
{
    return test_main(ac, av);
}