Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 1 | // Copyright (c) 2012 Google Inc. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #define offsetof(st, m) ((unsigned)((char*)&((st*)0)->m - (char*)0)) | ||||
6 | |||||
7 | struct MyStruct { | ||||
8 | virtual void MyFunc() = 0; | ||||
9 | int my_member; | ||||
10 | }; | ||||
11 | |||||
12 | int main() { | ||||
13 | unsigned x = offsetof(MyStruct, my_member); | ||||
14 | return x ? 0 : 1; | ||||
15 | } |