Go patch committed: Support //extern comments instead of __asm__

Ian Lance Taylor iant@google.com
Tue Feb 7 19:26:00 GMT 2012


The Go compiler currently supports using __asm__ in Go code to set the
externally visible name of a function declaration.  This is used to
permit Go code to call C code directly.  The problem with __asm__ is
that it is not supported by the gofmt program, which means that Go code
that uses can not be formatted automatically.  This patch adds a new
feature to gccgo: a function declaration may now be preceded by a
comment "//extern NAME" which sets the external name of the function
declaration.  Those comments are otherwise ignored.  This permits the
code to be run through gofmt without any trouble.  The existing __asm__
syntax remains as there is code out there which uses it.  It will be
removed in the future.  This patch changes the compiler to support
//extern and changes libgo to use it.  Bootstrapped and ran Go testsuite
on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian


2012-02-07  Ian Lance Taylor  <iant@google.com>

	* gccgo.texi (Function Names): Document //extern instead of
	__asm__.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-diff
Size: 22054 bytes
Desc: patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120207/c5f76bd0/attachment.bin>


More information about the Gcc-patches mailing list