mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-03 12:21:23 +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:
@@ -25,7 +25,9 @@
|
||||
namespace flatbuffers {
|
||||
namespace java {
|
||||
|
||||
Namer::Config JavaDefaultConfig() {
|
||||
namespace {
|
||||
|
||||
static Namer::Config JavaDefaultConfig() {
|
||||
return {
|
||||
/*types=*/Case::kKeep,
|
||||
/*constants=*/Case::kScreamingSnake,
|
||||
@@ -50,7 +52,7 @@ Namer::Config JavaDefaultConfig() {
|
||||
};
|
||||
}
|
||||
|
||||
std::set<std::string> JavaKeywords() {
|
||||
static std::set<std::string> JavaKeywords() {
|
||||
return {
|
||||
"abstract", "continue", "for", "new", "switch",
|
||||
"assert", "default", "goto", "package", "synchronized",
|
||||
@@ -65,16 +67,18 @@ std::set<std::string> JavaKeywords() {
|
||||
};
|
||||
}
|
||||
|
||||
static TypedFloatConstantGenerator JavaFloatGen("Double.", "Float.", "NaN",
|
||||
static const TypedFloatConstantGenerator JavaFloatGen("Double.", "Float.", "NaN",
|
||||
"POSITIVE_INFINITY",
|
||||
"NEGATIVE_INFINITY");
|
||||
|
||||
static CommentConfig comment_config = {
|
||||
static const CommentConfig comment_config = {
|
||||
"/**",
|
||||
" *",
|
||||
" */",
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
class JavaGenerator : public BaseGenerator {
|
||||
struct FieldArrayLength {
|
||||
std::string name;
|
||||
|
||||
Reference in New Issue
Block a user