diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-07-27 16:01:55 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-07-27 17:47:59 -0700 |
commit | 6e1eeeebfb453fa7c871869c19375ce60fbd7413 (patch) | |
tree | 539c4a3fdf1756ae79770d5c4aaf6366f1d1525e /000organization.cc | |
parent | 8846a7f85cc04b77b2fe8a67b6d317723437b00c (diff) | |
download | mu-6e1eeeebfb453fa7c871869c19375ce60fbd7413.tar.gz |
5485 - promote SubX to top-level
Diffstat (limited to '000organization.cc')
-rw-r--r-- | 000organization.cc | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/000organization.cc b/000organization.cc index 9a1938ff..87004af5 100644 --- a/000organization.cc +++ b/000organization.cc @@ -94,7 +94,7 @@ // Types // End Types -// Function prototypes are auto-generated in the 'build*' scripts; define your +// Function prototypes are auto-generated in the 'build' script; define your // functions in any order. Just be sure to declare each function header all on // one line, ending with the '{'. Our auto-generation scripts are too minimal // and simple-minded to handle anything else. @@ -103,7 +103,7 @@ // Globals // // All statements in this section should always define a single variable on a -// single line. The 'build*' scripts will simple-mindedly auto-generate extern +// single line. The 'build' script will simple-mindedly auto-generate extern // declarations for them. Remember to define (not just declare) constants with // extern linkage in this section, since C++ global constants have internal // linkage by default. @@ -112,25 +112,51 @@ int main(int argc, char* argv[]) { atexit(reset); + // we require a 32-bit little-endian system + assert(sizeof(int) == 4); + assert(sizeof(float) == 4); + assert_little_endian(); // End One-time Setup // Commandline Parsing // End Commandline Parsing - return 0; // End Main + // End Main + + return 0; } // Unit Tests // End Unit Tests -//: our first directive; insert the following header at the start of the program +//: our first directive; insert the following headers at the start of the program :(before "End Includes") +#include <assert.h> #include <stdlib.h> //: Without directives or with the :(code) directive, lines get added at the //: end. +//: +//: Regardless of where functions are defined, we can call them anywhere we +//: like as long as we format the function header in a specific way: put it +//: all on a single line without indent, end the line with ') {' and no +//: trailing whitespace. As long as functions uniformly start this way, our +//: 'build' script contains a little command to automatically generate +//: declarations for them. :(code) void reset() { // End Reset } + +void assert_little_endian() { + const int x = 1; + const char* y = reinterpret_cast<const char*>(&x); + if (*y != 1) { + cerr << "SubX requires a little-endian processor. Do you have Intel (or AMD or Atom) inside?\n"; + exit(1); + } +} +:(before "End Includes") +#include<iostream> +using std::cerr; |