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?
-
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.– user142019Mar 31, 2013 at 22:50
-
6C does not use the cdecl calling convention. Some implementations use it, and some use other calling conventions.– nosMar 31, 2013 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)– fuzApr 1, 2013 at 11:34
1 Answer
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.