You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2011/08/19 13:25:39 UTC

svn commit: r1159593 - in /thrift/trunk/compiler/cpp/src: globals.h main.cc thrifty.yy

Author: roger
Date: Fri Aug 19 11:25:39 2011
New Revision: 1159593

URL: http://svn.apache.org/viewvc?rev=1159593&view=rev
Log:
THRIFT-1276 Add thrift compiler option to suppress warnings about
Patch: Dave Watson

Modified:
    thrift/trunk/compiler/cpp/src/globals.h
    thrift/trunk/compiler/cpp/src/main.cc
    thrift/trunk/compiler/cpp/src/thrifty.yy

Modified: thrift/trunk/compiler/cpp/src/globals.h
URL: http://svn.apache.org/viewvc/thrift/trunk/compiler/cpp/src/globals.h?rev=1159593&r1=1159592&r2=1159593&view=diff
==============================================================================
--- thrift/trunk/compiler/cpp/src/globals.h (original)
+++ thrift/trunk/compiler/cpp/src/globals.h Fri Aug 19 11:25:39 2011
@@ -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

Modified: thrift/trunk/compiler/cpp/src/main.cc
URL: http://svn.apache.org/viewvc/thrift/trunk/compiler/cpp/src/main.cc?rev=1159593&r1=1159592&r2=1159593&view=diff
==============================================================================
--- thrift/trunk/compiler/cpp/src/main.cc (original)
+++ thrift/trunk/compiler/cpp/src/main.cc Fri Aug 19 11:25:39 2011
@@ -157,6 +157,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
  */
 bool gen_cpp = false;
@@ -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) {

Modified: thrift/trunk/compiler/cpp/src/thrifty.yy
URL: http://svn.apache.org/viewvc/thrift/trunk/compiler/cpp/src/thrifty.yy?rev=1159593&r1=1159592&r2=1159593&view=diff
==============================================================================
--- thrift/trunk/compiler/cpp/src/thrifty.yy (original)
+++ thrift/trunk/compiler/cpp/src/thrifty.yy Fri Aug 19 11:25:39 2011
@@ -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);
       }
     }