about summary refs log tree commit diff stats
path: root/003trace.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-08-28 18:12:03 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-08-28 18:37:57 -0700
commit5f05e954ee1f1daf953b3ff20af81775f226d5bf (patch)
tree21a691619f0e260e18df4140d4d8381682ecd979 /003trace.cc
parentc7fde8d4e4175b436bc8db92bedd231261827e2c (diff)
downloadmu-5f05e954ee1f1daf953b3ff20af81775f226d5bf.tar.gz
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)
Diffstat (limited to '003trace.cc')
-rw-r--r--003trace.cc10
1 files changed, 6 insertions, 4 deletions
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