Source file misc/cgo/test/testdata/issue27340/a.go

     1  // Copyright 2018 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Failed to resolve typedefs consistently.
     6  // No runtime test; just make sure it compiles.
     7  // In separate directory to isolate #pragma GCC diagnostic.
     8  
     9  package issue27340
    10  
    11  // We use the #pragma to avoid a compiler warning about incompatible
    12  // pointer types, because we generate code passing a struct ptr rather
    13  // than using the typedef. This warning is expected and does not break
    14  // a normal build.
    15  // We can only disable -Wincompatible-pointer-types starting with GCC 5.
    16  
    17  // #if __GNU_MAJOR__ >= 5
    18  //
    19  // #pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
    20  //
    21  // typedef struct {
    22  // 	int a;
    23  // } issue27340Struct, *issue27340Ptr;
    24  //
    25  // static void issue27340CFunc(issue27340Ptr p) {}
    26  //
    27  // #else /* _GNU_MAJOR_ < 5 */
    28  //
    29  // typedef struct {
    30  // 	int a;
    31  // } issue27340Struct;
    32  //
    33  // static issue27340Struct* issue27340Ptr(issue27340Struct* p) { return p; }
    34  //
    35  // static void issue27340CFunc(issue27340Struct *p) {}
    36  // #endif /* _GNU_MAJOR_ < 5 */
    37  import "C"
    38  
    39  func Issue27340GoFunc() {
    40  	var s C.issue27340Struct
    41  	C.issue27340CFunc(C.issue27340Ptr(&s))
    42  }
    43  

View as plain text