|
@@ -1,5 +1,12 @@
|
|
|
open Ast
|
|
open Ast
|
|
|
|
|
|
|
|
|
|
+(* Unix command to call for C preprocessor:
|
|
|
|
|
+ * -nostdinc : don't include from C stdlib
|
|
|
|
|
+ * -C : don't remove comments
|
|
|
|
|
+ * -traditional-cpp : don't remove excessive whitespaces, so that error
|
|
|
|
|
+ * messages preserve correct character locations *)
|
|
|
|
|
+let cpp_cmd = "cpp -nostdinc -C -traditional-cpp"
|
|
|
|
|
+
|
|
|
let input_all ic =
|
|
let input_all ic =
|
|
|
let n = in_channel_length ic in
|
|
let n = in_channel_length ic in
|
|
|
let buf = String.create n in
|
|
let buf = String.create n in
|
|
@@ -33,10 +40,10 @@ let phase ir =
|
|
|
if args.cpp then
|
|
if args.cpp then
|
|
|
let cpp_out = match args.infile with
|
|
let cpp_out = match args.infile with
|
|
|
| Some filename ->
|
|
| Some filename ->
|
|
|
- Unix.open_process_in ("cpp " ^ filename)
|
|
|
|
|
|
|
+ Unix.open_process_in (cpp_cmd ^ " " ^ filename)
|
|
|
| None ->
|
|
| None ->
|
|
|
let content = input_buffered stdin bufsize in
|
|
let content = input_buffered stdin bufsize in
|
|
|
- let (cpp_out, cpp_in) = Unix.open_process "cpp" in
|
|
|
|
|
|
|
+ let (cpp_out, cpp_in) = Unix.open_process cpp_cmd in
|
|
|
output_string cpp_in content;
|
|
output_string cpp_in content;
|
|
|
close_out cpp_in;
|
|
close_out cpp_in;
|
|
|
cpp_out
|
|
cpp_out
|