From: Roger Meier Date: Fri, 19 Aug 2011 11:25:39 +0000 (+0000) Subject: THRIFT-1276 Add thrift compiler option to suppress warnings about X-Git-Tag: 0.8.0~141 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=887ff756cb6ead9d5b764064ffc4973be8065b59;p=common%2Fthrift.git THRIFT-1276 Add thrift compiler option to suppress warnings about Patch: Dave Watson git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1159593 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/src/globals.h b/compiler/cpp/src/globals.h index b856a61d..2b1865b9 100644 --- a/compiler/cpp/src/globals.h +++ b/compiler/cpp/src/globals.h @@ -129,4 +129,13 @@ extern int g_doctext_lineno; */ extern int g_allow_neg_field_keys; +/** + * Whether or not 64-bit constants will generate a warning. + * + * Some languages don't support 64-bit constants, but many do, so we can + * suppress this warning for projects that don't use any non-64-bit-safe + * languages. + */ +extern int g_allow_64bit_consts; + #endif diff --git a/compiler/cpp/src/main.cc b/compiler/cpp/src/main.cc index da86d0d8..892ae207 100644 --- a/compiler/cpp/src/main.cc +++ b/compiler/cpp/src/main.cc @@ -156,6 +156,11 @@ int g_doctext_lineno; */ int g_allow_neg_field_keys; +/** + * Whether or not 64-bit constants will generate a warning. + */ +int g_allow_64bit_consts = 0; + /** * Flags to control code generation */ @@ -647,6 +652,7 @@ void usage() { fprintf(stderr, " --allow-neg-keys Allow negative field keys (Used to " "preserve protocol\n"); fprintf(stderr, " compatibility with older .thrift files)\n"); + fprintf(stderr, " --allow-64bit-consts Do not print warnings about using 64-bit constants\n"); fprintf(stderr, " --gen STR Generate code with a dynamically-registered generator.\n"); fprintf(stderr, " STR has the form language[:key1=val1[,key2,[key3=val3]]].\n"); fprintf(stderr, " Keys and values are options passed to the generator.\n"); @@ -980,6 +986,8 @@ int main(int argc, char** argv) { gen_recurse = true; } else if (strcmp(arg, "-allow-neg-keys") == 0) { g_allow_neg_field_keys = true; + } else if (strcmp(arg, "-allow-64bit-consts") == 0) { + g_allow_64bit_consts = true; } else if (strcmp(arg, "-gen") == 0) { arg = argv[++i]; if (arg == NULL) { diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy index f50c1e2f..c916604d 100644 --- a/compiler/cpp/src/thrifty.yy +++ b/compiler/cpp/src/thrifty.yy @@ -618,7 +618,7 @@ ConstValue: pdebug("ConstValue => tok_int_constant"); $$ = new t_const_value(); $$->set_integer($1); - if ($1 < INT32_MIN || $1 > INT32_MAX) { + if (!g_allow_64bit_consts && ($1 < INT32_MIN || $1 > INT32_MAX)) { pwarning(1, "64-bit constant \"%"PRIi64"\" may not work in all languages.\n", $1); } }