Insane cgo directives

In the document of cgo, it says:

If the import of “C” is immediately preceded by a comment, that comment, called the preamble, is used as a header when compiling the C parts of the package.

For example, the following is correct:

// #cgo linux CFLAGS: -I/opt/jdk/include -I/opt/jdk/include/linux
// #cgo linux LDFLAGS: -Llib -lhdfs -L/opt/jdk/jre/lib/amd64/server -ljvm
// #cgo darwin CFLAGS: -I/usr/local/hdfs/include
// #cgo darwin LDFLAGS: -L/usr/local/hdfs/lib -lhdfs -framework JavaVM
// #include "hdfs.h"
import "C"

But I inserted an empty line before #include "hdfs.h" in mistake, then all cgo directives (CFLAGS and LDFLAGS) disappeared from the command line invoking gcc, and on Mac OS X I got an error message “Undefined symbols for architecture x86_64:”, which led me to check whether I had built libhdfs correctly into x86_64 with my newly upgraded Mountain Lion and Xcode 4.5. This stupid checking cost me an hour!

A side effect is that I found go build -a -x is useful as it prints commands when building.

Hey, dear Go community, could you please change the rule to

all comments before the line #import "C" count as the preamble.

 

About these ads

2 Responses to Insane cgo directives

  1. Snoring is actually a sound produced within the upper airway from the throat.
    Occasionally it really is an excruciating loud noise even though other occasions it’s a light snore. Nonetheless, each might be equally as irritating. It appears the probabilities of snoring boost with age and with body mass. Most people who didn’t snore when they were younger, wind up
    snoring when they hit their 40’s (often even younger than that). Also, those who are overweight are more likely to snore than those who are physically fit. The several aspects which influence snoring make it tough to pinpoint the exact answer to the issue. So is there actually a answer to this dilemma?

  2. Kory says:

    I’m not sure where you are getting your info, but good topic.
    I needs to spend some time learning much more or understanding more.
    Thanks for fantastic information I was looking for this information for my mission.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 31 other followers

%d bloggers like this: