a.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // Failed to resolve typedefs consistently.
  5. // No runtime test; just make sure it compiles.
  6. // In separate directory to isolate #pragma GCC diagnostic.
  7. package issue27340
  8. // We use the #pragma to avoid a compiler warning about incompatible
  9. // pointer types, because we generate code passing a struct ptr rather
  10. // than using the typedef. This warning is expected and does not break
  11. // a normal build.
  12. // We can only disable -Wincompatible-pointer-types starting with GCC 5.
  13. // #if __GNU_MAJOR__ >= 5
  14. //
  15. // #pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
  16. //
  17. // typedef struct {
  18. // int a;
  19. // } issue27340Struct, *issue27340Ptr;
  20. //
  21. // static void issue27340CFunc(issue27340Ptr p) {}
  22. //
  23. // #else /* _GNU_MAJOR_ < 5 */
  24. //
  25. // typedef struct {
  26. // int a;
  27. // } issue27340Struct;
  28. //
  29. // static issue27340Struct* issue27340Ptr(issue27340Struct* p) { return p; }
  30. //
  31. // static void issue27340CFunc(issue27340Struct *p) {}
  32. // #endif /* _GNU_MAJOR_ < 5 */
  33. import "C"
  34. func Issue27340GoFunc() {
  35. var s C.issue27340Struct
  36. C.issue27340CFunc(C.issue27340Ptr(&s))
  37. }