Skip to content

Instantly share code, notes, and snippets.

@vbatts
Created April 9, 2015 14:02
Show Gist options
  • Save vbatts/d3586e703147c6797a69 to your computer and use it in GitHub Desktop.
Save vbatts/d3586e703147c6797a69 to your computer and use it in GitHub Desktop.
FORTIFY_SOURCE
#!/bin/sh
# build and see output
go build -x c.go
# if you link to outside libraries
#go build -ldflags '-extldflags "-DFORTIFY_SOURCE"' -x c.go
package main
/*
#cgo CFLAGS: -DFORTIFY_SOURCE
#include <stdio.h>
void foo(const char* msg) {
printf(msg);
}
*/
import "C"
func main() {
C.foo(C.CString("whoop whoop\n"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment