summaryrefslogtreecommitdiff
path: root/cffi
diff options
context:
space:
mode:
Diffstat (limited to 'cffi')
-rw-r--r--cffi/cparser.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/cffi/cparser.py b/cffi/cparser.py
index 9cb3412..c275f42 100644
--- a/cffi/cparser.py
+++ b/cffi/cparser.py
@@ -156,6 +156,13 @@ def _warn_for_string_literal(csource):
"confuse pre-parsing.")
break
+def _warn_for_non_extern_non_static_global_variable(decl):
+ if not decl.storage:
+ import warnings
+ warnings.warn("Declaration of global variable '%s' in cdef() should "
+ "be marked 'extern' for consistency (or possibly "
+ "'static' in API mode)" % (decl.name,))
+
def _preprocess(csource):
# Remove comments. NOTE: this only work because the cdef() section
# should not contain any string literal!
@@ -506,6 +513,7 @@ class Parser(object):
if (quals & model.Q_CONST) and not tp.is_array_type:
self._declare('constant ' + decl.name, tp, quals=quals)
else:
+ _warn_for_non_extern_non_static_global_variable(decl)
self._declare('variable ' + decl.name, tp, quals=quals)
def parse_type(self, cdecl):