mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-21 22:28:28 +00:00
Audit and fixups for GCC and Clang (#7212)
Added (for compiler versions that support it): -Wmissing-declarations -Wzero-as-null-pointer-constant Then, fixes to problems identified by the extra warnings Tested only on GCC 9.4.0 Adjusted the CPP code generator to output nullptr where appropriate, to satisfy -Wzero-as-null-pointer-constant Added a lot of 'static' declarations in front of functions, to satisfy -Wmissing-declarations, and wrap static function defs in anonymous namespaces. There are advantages to both anonymous namespaces and static, it seems that marking a function as static will not publish the name in the symbol table at all, thus giving the linker less work to do.
This commit is contained in:
@@ -38,8 +38,10 @@ namespace flatbuffers {
|
||||
|
||||
namespace go {
|
||||
|
||||
namespace {
|
||||
|
||||
// see https://golang.org/ref/spec#Keywords
|
||||
std::set<std::string> GoKeywords() {
|
||||
static std::set<std::string> GoKeywords() {
|
||||
return {
|
||||
"break", "default", "func", "interface", "select",
|
||||
"case", "defer", "go", "map", "struct",
|
||||
@@ -49,7 +51,7 @@ std::set<std::string> GoKeywords() {
|
||||
};
|
||||
}
|
||||
|
||||
Namer::Config GoDefaultConfig() {
|
||||
static Namer::Config GoDefaultConfig() {
|
||||
// Note that the functions with user defined types in the name use
|
||||
// upper camel case for all but the user defined type itself, which is keep
|
||||
// cased. Despite being a function, we interpret it as a Type.
|
||||
@@ -75,6 +77,8 @@ Namer::Config GoDefaultConfig() {
|
||||
/*filename_extension=*/".go" };
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
class GoGenerator : public BaseGenerator {
|
||||
public:
|
||||
GoGenerator(const Parser &parser, const std::string &path,
|
||||
|
||||
Reference in New Issue
Block a user