source: trunk/testcase/weak/weak2-main.c@ 1798

Last change on this file since 1798 was 1191, checked in by bird, 22 years ago

more/fixed.

  • Property cvs2svn:cvs-rev set to 1.4
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.4 KB
RevLine 
[306]1/* test more complex weak stuff. Both weak symbols and weak external symbols. */
2#include <stdio.h>
3extern int bar1;
4extern int bar2;
5extern int bar3;
6extern int bar4;
7extern int bar5;
8extern int bar6;
9
[1187]10extern int weak_not_defined(void);
11#pragma weak weak_not_defined
12
[1191]13extern int weak_defined(void);
14#pragma weak weak_not_defined
15
[306]16int main()
17{
18 int i;
19 int cErrors = 0;
20
21 i = foo();
22 if (i != 1)
23 {
[1191]24 printf("foo() returned %d, expected 1\n", i);
[306]25 cErrors++;
26 }
27
28 i = foo3();
29 if (i != 1)
30 {
[1191]31 printf("foo3() returned %d, expected 1\n", i);
[306]32 cErrors++;
33 }
34
35 i = foo4();
36 if (i != -1)
37 {
[1191]38 printf("foo4() returned %d, expected -1\n", i);
[306]39 cErrors++;
40 }
41
42 i = foo5();
43 if (i != 1)
44 {
[1191]45 printf("foo5() returned %d, expected 1\n", i);
[306]46 cErrors++;
47 }
48
49 i = foo6();
50 if (i != 12)
51 {
[1191]52 printf("foo6() returned %d, expected 12\n", i);
[306]53 cErrors++;
54 }
55
56 i = bar1 + bar2 + bar3 + bar4 + bar5 + bar6;
[307]57 if (i != 21)
[306]58 {
[1191]59 printf("bar sum is %d expected 21\n", i);
[306]60 cErrors++;
61 }
62
[1187]63 if (weak_not_defined)
64 {
[1191]65 printf("weak_not_defined %#p expected NULL\n", weak_not_defined);
[1187]66 cErrors++;
67 }
68
[1191]69 if (!weak_defined)
70 {
71 printf("weak_not_defined %#p expected non-zero\n", weak_defined);
72 cErrors++;
73 }
74
[306]75 return cErrors;
76}
Note: See TracBrowser for help on using the repository browser.