aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcppawk3
-rw-r--r--cppawk-include/stdver.h1
-rw-r--r--cppawk.112
-rw-r--r--testcases8
4 files changed, 24 insertions, 0 deletions
diff --git a/cppawk b/cppawk
index ebf9ff1..f7d0c33 100755
--- a/cppawk
+++ b/cppawk
@@ -39,6 +39,7 @@ awk_opts=
tmp_file=
delhashbang="sed -e /^#!/d --"
prepro_only=
+selfdir=$(dirname "$0")
# functions
@@ -69,6 +70,8 @@ die()
exit 1
}
+prepro_opts="$prepro_opts -I$selfdir/cppawk-include"
+
while [ $# -gt 0 ] ; do
case $1 in
-M?* )
diff --git a/cppawk-include/stdver.h b/cppawk-include/stdver.h
new file mode 100644
index 0000000..468b993
--- /dev/null
+++ b/cppawk-include/stdver.h
@@ -0,0 +1 @@
+#define __cppawk_ver 20220318
diff --git a/cppawk.1 b/cppawk.1
index 42902a6..fc86e38 100644
--- a/cppawk.1
+++ b/cppawk.1
@@ -97,6 +97,18 @@ Options which match these patterns are passed to the
program instead of
.BR awk .
+.SH STANDARD HEADERS
+.B cppawk
+points the preprocessor to look for
+.BI "#include <...>"
+files in its own directory. The
+.BI "<stdver.h>"
+header defines a preprocessor symbol
+.BI __cppawk_ver
+whose value is a decimal integer the form
+.IR YYYYMMDD ,
+such as 20220318.
+
.SH EXAMPLES
Print the larger of field 1 or 2:
diff --git a/testcases b/testcases
index caef473..091f19d 100644
--- a/testcases
+++ b/testcases
@@ -153,3 +153,11 @@ abc
./cppawk -v foo="abc'def" 'BEGIN { print foo }'
:
abc'def
+--
+29:
+./cppawk '
+#include <stdver.h>
+
+BEGIN { print __cppawk_ver >= 20220318 }'
+:
+1