50 lines · cpp
1namespace cpp_namespace {2 struct CppStruct {3 int field = 1111;4 5 int function() {6 return 2222;7 }8 };9 10 union CppUnion {11 char field_char;12 short field_short;13 int field_int;14 };15 16 CppStruct GetCppStruct() {17 return CppStruct();18 }19 20 CppStruct global;21 22 CppStruct *GetCppStructPtr() {23 return &global;24 }25}26 27int global = 3333;28 29int main()30{31 cpp_namespace::CppStruct cpp_struct = cpp_namespace::GetCppStruct();32 cpp_struct.function();33 34 cpp_namespace::CppStruct &cpp_struct_ref = cpp_struct;35 cpp_struct_ref.function();36 37 int field = 4444;38 39 cpp_namespace::CppUnion cpp_union;40 cpp_union.field_int = 5555;41 42 int cpp_scalar = 6666;43 44 cpp_namespace::CppStruct cpp_array[16];45 46 cpp_namespace::CppStruct *cpp_pointer = cpp_namespace::GetCppStructPtr();47 48 return 0; // Break here49}50