THRIFT-1270. compiler: add --allow-neg-keys argument to allow
This switch allows the user to specify explicit negative field IDs in Thrift IDL in order to avoid breaking wire protocol.
Patch: Dave Watson
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1158967 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/globals.h b/compiler/cpp/src/globals.h
index b204143..b856a61 100644
--- a/compiler/cpp/src/globals.h
+++ b/compiler/cpp/src/globals.h
@@ -114,4 +114,19 @@
*/
extern int g_doctext_lineno;
+/**
+ * Whether or not negative field keys are accepted.
+ *
+ * When a field does not have a user-specified key, thrift automatically
+ * assigns a negative value. However, this is fragile since changes to the
+ * file may unintentionally change the key numbering, resulting in a new
+ * protocol that is not backwards compatible.
+ *
+ * When g_allow_neg_field_keys is enabled, users can explicitly specify
+ * negative keys. This way they can write a .thrift file with explicitly
+ * specified keys that is still backwards compatible with older .thrift files
+ * that did not specify key values.
+ */
+extern int g_allow_neg_field_keys;
+
#endif