1
0
mirror of https://github.com/golang/go synced 2024-11-27 05:11:22 -07:00
The Go programming language
Go to file
Russ Cox 06ad3b2de1 cmd/cgo: stop using compiler error message text to analyze C names
The old approach to determining whether "name" was a type, constant,
or expression was to compile the C program

        name;

and scan the errors and warnings generated by the compiler.
This requires looking for specific substrings in the errors and warnings,
which ties the implementation to specific compiler versions.
As compilers change their errors or drop warnings, cgo breaks.
This happens slowly but it does happen.
Clang in particular (now required on OS X) has a significant churn rate.

The new approach compiles a slightly more complex program
that is either valid C or not valid C depending on what kind of
thing "name" is. It uses only the presence or absence of an error
message on a particular line, not the error text itself. The program is:

        // error if and only if name is undeclared
        void f1(void) { typeof(name) *x; }

        // error if and only if name is not a type
        void f2(void) { name *x; }

        // error if and only if name is not an integer constant
        void f3(void) { enum { x = (name)*1 }; }

I had not been planning to do this until Go 1.3, because it is a
non-trivial change, but it fixes a real Xcode 5 problem in Go 1.2,
and the new code is easier to understand than the old code.
It should be significantly more robust.

Fixes #6596.
Fixes #6612.

R=golang-dev, r, james, iant
CC=golang-dev
https://golang.org/cl/15070043
2013-10-18 15:56:25 -04:00
api api: add go1.2.txt, use in tests 2013-10-18 13:36:59 +09:00
doc spec: clarify re-use of underlying arrays in slice operations 2013-10-16 16:16:54 -07:00
include build: remove various uses of C undefined behavior 2013-09-09 15:07:23 -04:00
lib lib/codereview: return an empty list when CONTRIBUTORS is not found instead of None. 2013-10-10 17:16:17 -07:00
misc cmd/cgo: stop using compiler error message text to analyze C names 2013-10-18 15:56:25 -04:00
src cmd/cgo: stop using compiler error message text to analyze C names 2013-10-18 15:56:25 -04:00
test test: revert changes made for Go SSA interpreter test. 2013-10-08 14:36:20 -04:00
.hgignore build: ignore new zfiles, delete temp goplay binary in run.bash 2013-08-02 19:14:13 -07:00
.hgtags tag go1.2rc2 2013-10-18 14:01:00 +09:00
AUTHORS A+C: add Jamie Turner (Dropbox corporate CLA). 2013-10-17 11:48:27 +11:00
CONTRIBUTORS A+C: add Jamie Turner (Dropbox corporate CLA). 2013-10-17 11:48:27 +11:00
favicon.ico godoc: update favicon 2012-10-11 17:02:36 +11:00
LICENSE
PATENTS
README
robots.txt

This is the source code repository for the Go programming language.  

For documentation about how to install and use Go,
visit http://golang.org/ or load doc/install.html in your web browser.

After installing Go, you can view a nicely formatted
doc/install.html by running godoc --http=:6060
and then visiting http://localhost:6060/doc/install.html.

Unless otherwise noted, the Go source files are distributed
under the BSD-style license found in the LICENSE file.

--

Binary Distribution Notes

If you have just untarred a binary Go distribution, you need to set
the environment variable $GOROOT to the full path of the go
directory (the one containing this README).  You can omit the
variable if you unpack it into /usr/local/go, or if you rebuild
from sources by running all.bash (see doc/install.html).
You should also add the Go binary directory $GOROOT/bin
to your shell's path.

For example, if you extracted the tar file into $HOME/go, you might
put the following in your .profile:

    export GOROOT=$HOME/go
    export PATH=$PATH:$GOROOT/bin

See doc/install.html for more details.