From 5f05e954ee1f1daf953b3ff20af81775f226d5bf Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 28 Aug 2016 18:12:03 -0700 Subject: 3273 Undo 3272. The trouble with creating a new section for constants is that there's no good place to order it since constants can be initialized using globals as well as vice versa. And I don't want to add constraints disallowing either side. Instead, a new plan: always declare constants in the Globals section using 'extern const' rather than just 'const', since otherwise constants implicitly have internal linkage (http://stackoverflow.com/questions/14894698/why-does-extern-const-int-n-not-work-as-expected) --- 003trace.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to '003trace.cc') diff --git a/003trace.cc b/003trace.cc index 9368d282..05a2fa15 100644 --- a/003trace.cc +++ b/003trace.cc @@ -92,7 +92,9 @@ bool Hide_errors = false; Hide_errors = false; :(before "End Types") -// pre-define some globals that trace_stream needs to know about +// Pre-define some global constants that trace_stream needs to know about. +// Since they're in the Types section, they'll be included in any cleaved +// compilation units. So no extern linkage. const int Max_depth = 9999; const int Error_depth = 0; // definitely always print errors const int App_depth = 2; // temporarily where all mu code will trace to @@ -383,14 +385,14 @@ using std::ofstream; #include "termbox/termbox.h" -:(before "End Constants") +:(before "End Globals") //: In future layers we'll use the depth field as follows: //: //: Errors will be depth 0. //: Mu 'applications' will be able to use depths 1-100 as they like. //: Primitive statements will occupy 101-9989 -const int Initial_callstack_depth = 101; -const int Max_callstack_depth = 9989; +extern const int Initial_callstack_depth = 101; +extern const int Max_callstack_depth = 9989; //: Finally, details of primitive mu statements will occupy depth 9990-9999 (more on that later as well) //: //: This framework should help us hide some details at each level, mixing -- cgit 1.4.1-2-gfad0