Project

General

Profile

Revision e772c6ef

View differences:

src/c_backend.ml
668 668
(*                         C file Printing functions                                        *)
669 669
(********************************************************************************************)
670 670

  
671
let print_const fmt cdecl =
671
let print_const_def fmt cdecl =
672 672
  fprintf fmt "%a = %a;@." (pp_c_type cdecl.const_id) cdecl.const_type pp_c_const cdecl.const_value 
673 673

  
674
let print_const_decl fmt cdecl =
675
  fprintf fmt "extern %a;@." (pp_c_type cdecl.const_id) cdecl.const_type
676

  
674 677
let print_alloc_instance fmt (i, (m, static)) =
675 678
  fprintf fmt "_alloc->%s = %a (%a);@,"
676 679
    i
......
884 887
(********************************************************************************************)
885 888
(*                         Translation function                                             *)
886 889
(********************************************************************************************)
887
    
890

  
888 891
let translate_to_c header_fmt source_fmt makefile_fmt spec_fmt_opt basename prog machines dependencies =
889 892
  (* Generating H file *)
890 893

  
......
894 897
  (* Print the svn version number and the supported C standard (C90 or C99) *)
895 898
  print_version header_fmt;
896 899
  fprintf header_fmt "#ifndef _%s@.#define _%s@." baseNAME baseNAME;
900
  pp_print_newline header_fmt ();
901
  (* Print the global constant declarations. *)
902
  fprintf header_fmt "/* Global constant (declarations, definitions are in C file) */@.";
903
  List.iter (fun c -> print_const_decl header_fmt c) (get_consts prog);
904
  pp_print_newline header_fmt ();
897 905
  (* Print the struct declarations of all machines. *)
898 906
  fprintf header_fmt "/* Struct declarations */@.";
899 907
  List.iter (print_machine_struct header_fmt) machines;
......
907 915
  pp_print_newline header_fmt ();
908 916

  
909 917
  (* Generating C file *)
910
  
918

  
911 919
  (* If a main node is identified, generate a main function for it *)
912 920
  let main_include, main_print, main_makefile =
913 921
    match !Options.main_node with
......
930 938
  (* Print the type definitions from the type table *)
931 939
  print_type_definitions source_fmt;
932 940
  (* Print consts *)
933
  fprintf source_fmt "/* Global constants */@.";
934
  List.iter (fun c -> print_const source_fmt c) (get_consts prog); 
941
  fprintf source_fmt "/* Global constants (definitions) */@.";
942
  List.iter (fun c -> print_const_def source_fmt c) (get_consts prog);
935 943
  pp_print_newline source_fmt ();
936 944
  (* Print nodes one by one (in the previous order) *)
937 945
  List.iter (print_machine source_fmt) machines;
938 946
  main_print source_fmt;
939 947

  
940 948
  (* Generating Makefile *)
941
  main_makefile makefile_fmt    
949
  main_makefile makefile_fmt
942 950

  
943 951
(* Local Variables: *)
944 952
(* compile-command:"make -C .." *)

Also available in: Unified diff