[594] | 1 | typedef struct some_struct_pointer * PTYPE;
|
---|
| 2 |
|
---|
| 3 | /*
|
---|
| 4 | * Function and method declarations.
|
---|
| 5 | * Checks mangling.
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | /* No underscore, No mangling. */
|
---|
| 9 | extern "C" void _System ExternCVoid(void);
|
---|
| 10 | extern "C" void * _System ExternCPVoid(void);
|
---|
| 11 | extern "C" int _System ExternCInt(void);
|
---|
| 12 | extern "C" PTYPE _System ExternCPType(void);
|
---|
| 13 |
|
---|
| 14 | /* No underscore, No mangling. */
|
---|
| 15 | void _System Void(void);
|
---|
| 16 | void * _System PVoid(void);
|
---|
| 17 | int _System Int(void);
|
---|
| 18 | PTYPE _System PType(void);
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 | /* Members are mangled. */
|
---|
| 22 | class foo
|
---|
| 23 | {
|
---|
| 24 | public:
|
---|
| 25 | static void _System StaticMemberVoid(void);
|
---|
| 26 | static void * _System StaticMemberPVoid(void);
|
---|
| 27 | static int _System StaticMemberInt(void);
|
---|
| 28 | static PTYPE _System StaticMemberPType(void);
|
---|
| 29 |
|
---|
| 30 | /* VAC365 allows this too, and actually mangles the
|
---|
| 31 | * calling convention into the name.
|
---|
| 32 | * _System: MemberVoid__3fooF__l2_v
|
---|
| 33 | * default: MemberVoid__3fooFv
|
---|
| 34 | * We don't need to support this, it's just a curiosity.
|
---|
| 35 | */
|
---|
| 36 | void _System MemberVoid(void);
|
---|
| 37 | void * _System MemberPVoid(void);
|
---|
| 38 | int _System MemberInt(void);
|
---|
| 39 | PTYPE _System MemberPType(void);
|
---|
| 40 | };
|
---|
| 41 |
|
---|
| 42 |
|
---|
| 43 | /*
|
---|
| 44 | * Typedefs.
|
---|
| 45 | * Checks that there is not warnings on these.
|
---|
| 46 | */
|
---|
| 47 | typedef void _System Typedef1Void(void);
|
---|
| 48 | typedef void * _System Typedef1PVoid(void);
|
---|
| 49 | typedef int _System Typedef1Int(void);
|
---|
| 50 | typedef PTYPE _System Typedef1PType(void);
|
---|
| 51 |
|
---|
| 52 | typedef void (_System Typedef2Void)(void);
|
---|
| 53 | typedef void * (_System Typedef2PVoid)(void);
|
---|
| 54 | typedef int (_System Typedef2Int)(void);
|
---|
| 55 | typedef PTYPE (_System Typedef2PType)(void);
|
---|
| 56 |
|
---|
| 57 | typedef void (* _System PTypedef1Void)(void);
|
---|
| 58 | typedef void * (* _System PTypedef1PVoid)(void);
|
---|
| 59 | typedef int (* _System PTypedef1Int)(void);
|
---|
| 60 | typedef PTYPE (* _System PTypedef1PType)(void);
|
---|
| 61 |
|
---|
[595] | 62 | /* Alternate writing which should have the same effect I think... */
|
---|
[594] | 63 | typedef void (_System * PTypedef2Void)(void);
|
---|
| 64 | typedef void * (_System * PTypedef2PVoid)(void);
|
---|
| 65 | typedef int (_System * PTypedef2Int)(void);
|
---|
| 66 | typedef PTYPE (_System * PTypedef2PType)(void);
|
---|
| 67 |
|
---|
| 68 |
|
---|
| 69 | /*
|
---|
| 70 | * Structures.
|
---|
| 71 | * Should not cause warnings.
|
---|
| 72 | */
|
---|
| 73 | typedef struct VFT
|
---|
| 74 | {
|
---|
[595] | 75 | void (* _System PStructMemberVoid)(void* pvThis);
|
---|
| 76 | void * (* _System PStructMemberPVoid)(void* pvThis);
|
---|
| 77 | int (* _System PStructMemberInt)(void* pvThis);
|
---|
| 78 | PTYPE (* _System PStructMemberPType)(void* pvThis);
|
---|
| 79 |
|
---|
| 80 | /* Alternate writing which should have the same effect I think... */
|
---|
| 81 | void ( _System * PStructMember2Void)(void* pvThis);
|
---|
| 82 | void * ( _System * PStructMember2PVoid)(void* pvThis);
|
---|
| 83 | int ( _System * PStructMember2Int)(void* pvThis);
|
---|
| 84 | PTYPE ( _System * PStructMember2PType)(void* pvThis);
|
---|
| 85 |
|
---|
[594] | 86 | } VFT, *PVFT;
|
---|
| 87 |
|
---|
| 88 |
|
---|
| 89 | extern "C" int DoC(void);
|
---|
| 90 | int main(void)
|
---|
| 91 | {
|
---|
| 92 | ExternCVoid();
|
---|
| 93 | ExternCPVoid();
|
---|
| 94 | ExternCInt();
|
---|
| 95 | ExternCPType();
|
---|
| 96 |
|
---|
| 97 | Void();
|
---|
| 98 | PVoid();
|
---|
| 99 | Int();
|
---|
| 100 | PType();
|
---|
| 101 |
|
---|
| 102 | foo::StaticMemberVoid();
|
---|
| 103 | foo::StaticMemberPVoid();
|
---|
| 104 | foo::StaticMemberInt();
|
---|
| 105 | foo::StaticMemberPType();
|
---|
| 106 |
|
---|
| 107 | foo obj;
|
---|
| 108 | obj.MemberVoid();
|
---|
| 109 | obj.MemberPVoid();
|
---|
| 110 | obj.MemberInt();
|
---|
| 111 | obj.MemberPType();
|
---|
| 112 |
|
---|
| 113 | VFT vft = {0,0,0,0};
|
---|
| 114 | if (vft.PStructMemberVoid)
|
---|
| 115 | vft.PStructMemberVoid(&vft);
|
---|
| 116 | if (vft.PStructMemberPVoid)
|
---|
| 117 | vft.PStructMemberPVoid(&vft);
|
---|
| 118 | if (vft.PStructMemberInt)
|
---|
| 119 | vft.PStructMemberInt(&vft);
|
---|
| 120 | if (vft.PStructMemberPType)
|
---|
| 121 | vft.PStructMemberPType(&vft);
|
---|
| 122 |
|
---|
[595] | 123 | /* test C stuff */
|
---|
[594] | 124 | DoC();
|
---|
| 125 |
|
---|
[595] | 126 | /** @todo test typedefs and structure field. */
|
---|
| 127 |
|
---|
[594] | 128 | return 0;
|
---|
| 129 | }
|
---|
| 130 |
|
---|