7

C uses the cdecl, which I've looked into and called with from assembly. It feels well enough, so why break the compatibility? Why was another convention needed?

galva
  • 1,253
  • 10
  • 17
  • Go allows multiple return values and gc uses segmented stacks. I'm not entirely sure, but I wouldn't be surprised if these features are related to the calling conventions. Afaik, the only way to return multiple values with cdecl is to return a pointer to a structure. –  Mar 31 '13 at 22:50
  • 6
    C does not use the cdecl calling convention. Some implementations use it, and some use other calling conventions. – nos Mar 31 '13 at 23:13
  • AFAIK the Google implementation of Go uses a calling convention that is equal to that of C except in the places where C can't express the concept Go uses (such as when there are multiple return values) – fuz Apr 01 '13 at 11:34

1 Answers1

5

Because there's no advantage in having the same calling convention. Go code and C code cannot call each other directly even when the calling convention would be the same because Go uses split stacks.

OTOH, it makes sense in gccgo, as gcc supports C split stacks for some architectures. And, IIRC, there the calling convention is because of that compatible. (More details here.)

Disclaimer: I didn't ever actually used gccgo.

zzzz
  • 87,403
  • 16
  • 175
  • 139