I'm playing around with calling C code in go. When I try to use printf
from go however, I get a warning about the format string not being a string literal:
package main
// #include <stdio.h>
import "C"
func main() {
C.printf(C.CString("Hello world
"));
}
Warning:
warning: format string is not a string literal (potentially insecure) [-Wformat-security]
How can I pass a string literal into a C function like printf
? Is there a function similar to C.CString()
that I can use, or is it impossible and I should ignore this warning?