mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 20:15:34 +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:
@@ -299,7 +299,10 @@ std::string SimpleFloatConstantGenerator::NaN(float v) const {
|
||||
return this->NaN(static_cast<double>(v));
|
||||
}
|
||||
|
||||
std::string JavaCSharpMakeRule(const bool java, const Parser &parser,
|
||||
|
||||
namespace {
|
||||
|
||||
static std::string JavaCSharpMakeRule(const bool java, const Parser &parser,
|
||||
const std::string &path,
|
||||
const std::string &file_name) {
|
||||
const std::string file_extension = java ? ".java" : ".cs";
|
||||
@@ -331,6 +334,9 @@ std::string JavaCSharpMakeRule(const bool java, const Parser &parser,
|
||||
return make_rule;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
std::string JavaMakeRule(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name) {
|
||||
return JavaCSharpMakeRule(true, parser, path, file_name);
|
||||
@@ -340,12 +346,16 @@ std::string CSharpMakeRule(const Parser &parser, const std::string &path,
|
||||
return JavaCSharpMakeRule(false, parser, path, file_name);
|
||||
}
|
||||
|
||||
std::string BinaryFileName(const Parser &parser, const std::string &path,
|
||||
namespace {
|
||||
|
||||
static std::string BinaryFileName(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name) {
|
||||
auto ext = parser.file_extension_.length() ? parser.file_extension_ : "bin";
|
||||
return path + file_name + "." + ext;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool GenerateBinary(const Parser &parser, const std::string &path,
|
||||
const std::string &file_name) {
|
||||
if (parser.opts.use_flexbuffers) {
|
||||
|
||||
Reference in New Issue
Block a user