summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2011-12-04 13:00:17 +0000
committerPeter Wu <lekensteyn@gmail.com>2011-12-04 13:00:17 +0000
commitb0fdcbbf06175cd503e5b0ecefa49759f9872dbd (patch)
tree9e8d1b39202fe17653d940a8166e62aea5a29683
parenta3e28c60b97fd96182727715ba15ed0cc713597a (diff)
downloadpp2cc-b0fdcbbf06175cd503e5b0ecefa49759f9872dbd.tar.gz
Add -Dmacro[=defn] and -Umacro support, remove mention of array support
-rw-r--r--README20
-rwxr-xr-xpp2cc.py11
2 files changed, 17 insertions, 14 deletions
diff --git a/README b/README
index 6adfb4a..3259f15 100644
--- a/README
+++ b/README
@@ -39,6 +39,8 @@ Options:
-D name
-D name=definition This option is passed to the cpp program, and acts like
adding #define name or #define name definition respectively
+ -U name This option is passed to the cpp program and acts like
+ adding #undef name
--no-cpp Disable the use of the C Preprocessor
Conformance with the K&R interpretation of C and feature support
@@ -52,7 +54,7 @@ A4 Identifiers - functions, variables (int) are supported. struct, union are
A4.1 Storage class - static is supported (actually, everything is static).
Automatic variables are supported.
A4.2-A4.3 Types - supported: int; unsupported: char, enum, float, double,
- struct, union, arrays, pointers
+ struct, union, pointers. Not supported: arrays
A4.4 Type qualifiers - volatile won't be supported, const is unsupported
A5 Objects and lvalues - not explicitly used, but assignment works
A6 Conversions of operands - not supported since everything is treated as
@@ -85,23 +87,19 @@ A7.18 Comma - supported
A7.19 Constant expressions - not checked
A8 Declarations
-A8.1 Storage class specifiers - unsupported
+A8.1 Storage class specifiers - static function and global variables are
+ supported, static local variables aren't
A8.2 Type specifiers - unsupported, everything is assumed to be int. void in
the meaning of "no value" is not checked. Const is not meaningfully
supported yet
A8.3 Structure and union declarations - unsupported
A8.4 Enumerations - unsupported
A8.5 Declarators - pointers and qualifiers are ignored, only a direct name is
- supported. An array can be declared without initialization as in:
- int a[2];
-A8.6 Meaning of declarators - pointer and arrays are supported, function is
+ supported. Unsupported: array
+A8.6 Meaning of declarators - pointer is supported, array is not. function is
supported without parameters and assumed to be an int function.
-A8.7 Initialization - Supported for an expression resulting in an int, arrays
- may be initialized with a list of expressions yielding a constant
- value, e.g. int a[2]={3,1+2};int b[]={2}; in If the number of
- initializers are larger than the dimension, the excess elements are
- discarded. Multi-dimensional arrays are not supported at
- initialization.
+A8.7 Initialization - Supported for an expression resulting in an int. Arrays
+ are unsupported
A8.8 Type names - not verified
A8.9 Typedef - won't be supported as we have int only
diff --git a/pp2cc.py b/pp2cc.py
index 27c0fa1..99585c4 100755
--- a/pp2cc.py
+++ b/pp2cc.py
@@ -1397,6 +1397,8 @@ Options:
-D name
-D name=definition This option is passed to the cpp program, and acts like
adding #define name or #define name definition respectively
+ -U name This option is passed to the cpp program and acts like
+ adding #undef name
--no-cpp Disable the use of the C Preprocessor
"""
try:
@@ -1421,9 +1423,12 @@ Options:
set_arg = "output_filename"
elif arg == "--tree":
settings["dump_parsed_files"] = True
- elif arg == "-D":
- settings["cpp_args"].append("-D")
- set_arg = "cpp_args"
+ elif arg[1] in ("D", "U"):
+ settings["cpp_args"].append(arg)
+ if len(arg) == 2:
+ # Support -Dmacro=defn and -D macro=defn and
+ # -Umacro and -U macro
+ set_arg = "cpp_args"
elif arg == "--no-cpp":
settings["use_cpp"] = False
elif arg == "-h" or arg == "--help" or arg == "--usage":