mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 04:04:19 +00:00
Add flatc '--cpp_std' switch (#5656)
* Add flatc '--cpp_std' switch and sandbox for C++17 code generator - Added 'flac --cpp_std legacy' for compatibility with old compilers (VS2010); - Added experimental switch 'flac --cpp_std c++17' for future development; - Added C++17 sandbox test_cpp17.cpp; - C++ code generator generates enums with explicit underlying type to avoid problems with the forward and backward schema compatibility; - Adjusted CMakeLists.txt, CI and generate code scripts to support of introduced '--cpp_std'; * Fix --cpp_std values: c++0x, c++11, c++17 * Add 'cpp::CppStandard' enum * Add testing engine into test_cpp17 * Rebase to upstream/master * Set default '--cpp-std C++0x' * Fix code generation (--cpp_std C++11) in CMakeLists.txt - Fix dependency declaration of grpctest target * Revert --cpp-std for the tests from explicit C++11 to flatc default value (C++0x)
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
3e8f15df90
commit
44bf719883
@@ -116,6 +116,11 @@ std::string FlatCompiler::GetUsageString(const char *program_name) const {
|
||||
" (see the --cpp-str-flex-ctor option to change this behavior).\n"
|
||||
" --cpp-str-flex-ctor Don't construct custom string types by passing std::string\n"
|
||||
" from Flatbuffers, but (char* + length).\n"
|
||||
" --cpp-std CPP_STD Generate a C++ code using features of selected C++ standard.\n"
|
||||
" Supported CPP_STD values:\n"
|
||||
" * 'c++0x' - generate code compatible with old compilers;\n"
|
||||
" * 'c++11' - use C++11 code generator (default);\n"
|
||||
" * 'c++17' - use C++17 features in generated code (experimental).\n"
|
||||
" --object-prefix Customise class prefix for C++ object-based API.\n"
|
||||
" --object-suffix Customise class suffix for C++ object-based API.\n"
|
||||
" Default value is \"T\".\n"
|
||||
@@ -281,7 +286,7 @@ int FlatCompiler::Compile(int argc, const char **argv) {
|
||||
opts.include_dependence_headers = false;
|
||||
} else if (arg == "--gen-includes") {
|
||||
// Deprecated, remove this option some time in the future.
|
||||
printf("warning: --gen-includes is deprecated (it is now default)\n");
|
||||
Warn("warning: --gen-includes is deprecated (it is now default)\n");
|
||||
} else if (arg == "--no-includes") {
|
||||
opts.include_dependence_headers = false;
|
||||
} else if (arg == "--gen-onefile") {
|
||||
@@ -333,6 +338,9 @@ int FlatCompiler::Compile(int argc, const char **argv) {
|
||||
opts.java_primitive_has_method = true;
|
||||
} else if (arg == "--flexbuffers") {
|
||||
opts.use_flexbuffers = true;
|
||||
} else if(arg == "--cpp-std") {
|
||||
if (++argi >= argc) Error("missing C++ standard specification" + arg, true);
|
||||
opts.cpp_std = argv[argi];
|
||||
} else {
|
||||
for (size_t i = 0; i < params_.num_generators; ++i) {
|
||||
if (arg == params_.generators[i].generator_opt_long ||
|
||||
|
||||
Reference in New Issue
Block a user