<a name="l5"></a>* See </span><a href="/Wb/Doc/ScopingLinkage.DD.HTML#l1"><span class=cF4>Scoping and Linkage</span></a><span class=cF0> for details on </span><span class=cF2>extern</span><span class=cF0>, </span><span class=cF2>import</span><span class=cF0>, </span><span class=cF2>_extern</span><span class=cF0>, </span><span class=cF2>_import</span><span class=cF0>, etc.
<a name="l7"></a>* Built-in types include </span><span class=cF2>I0,I8,I16,I32,I64</span><span class=cF0> for signed 0-8 byte ints and </span><span class=cF2>U0,U8,U1
<a name="l8"></a>6,U32,U64</span><span class=cF0> for unsigned 0-8 byte ints and </span><span class=cF2>F64</span><span class=cF0> for 8 byte floats.
<a name="l9"></a>
<a name="l10"></a></span><span class=cF2> U0 void, but ZERO size!
<a name="l36"></a>* A char const all alone is sent to </span><a href="/Wb/Kernel/KeyDev.HC#l20"><span class=cF4>PutChars</span></a><span class=cF0>(). A string with or without args
<a name="l37"></a>is sent to </span><a href="/Wb/Kernel/StrPrint.HC#l890"><span class=cF4>Print</span></a><span class=cF0>(). An empty string literal signals a variable fmt_str follows.
<a name="l60"></a>* Type casting is postfix. To typecast int or F64, use </span><a href="/Wb/Kernel/KernelB.HH#l121"><span class=cF4>ToI64</span></a><span class=cF0>(), </span><a href="/Wb/Kernel/KernelB.HH#l119"><span class=cF4>ToBool</span></a><span class=cF0>() or </span><span class=cF4>
<a name="l61"></a></span><a href="/Wb/Kernel/KernelB.HH#l120"><span class=cF4>ToF64</span></a><span class=cF0>(). (TempleOS follows normal C float<-->int conversion, but sometimes you
<a name="l69"></a>bytes or words within any int. See </span><a href="/Wb/Kernel/KernelA.HH#l105"><span class=cF4>I64 declaration</span></a><span class=cF0>. A class can be accessed as
<a name="l70"></a>a whole are subints, if you put a type in front of the </span><span class=cF2>class</span><span class=cF0> declaration.
<a name="l71"></a>
<a name="l72"></a> </span><span class=cF2>public I64i union I64 //"I64i" is intrinsic. We are defining "I64".
<a name="l73"></a> {
<a name="l74"></a> I8i i8[8];
<a name="l75"></a> U8i u8[8];
<a name="l76"></a> I16 i16[4];
<a name="l77"></a> U16 u16[4];
<a name="l78"></a> I32 i32[2];
<a name="l79"></a> U32 u32[2];
<a name="l80"></a> };
<a name="l81"></a>
<a name="l82"></a> I64 i=0x123456780000DEF0;
<a name="l83"></a> i.u16[1]=0x9ABC;
<a name="l84"></a></span><span class=cF0>
<a name="l85"></a>* Variable arg count functions (</span><span class=cF2>...</span><span class=cF0>) can access their args with built-in
<a name="l86"></a>variables similar to '</span><span class=cF2>this</span><span class=cF0>' in C++. They are '</span><span class=cF2>I64 argc</span><span class=cF0>' and '</span><span class=cF2>I64 argv[]</span><span class=cF0>'.
<a name="l103"></a> </span><a href="/Wb/Adam/Gr/GrBitMap.HC#l913"><span class=cF4>GrPutS</span></a><span class=cF2>(dc,x,y,buf); //Plot string at x,y pixels. GrPutS is not public.
<a name="l119"></a>* if you know a switch stmt will not exceed the lowest or highest case values. </span><span class=cF2>
<a name="l120"></a>switch []</span><span class=cF0> is a little faster because it doesn't check.
<a name="l121"></a>
<a name="l122"></a>* </span><span class=cF2>switch</span><span class=cF0> stmts always use a jump table. Don't use them with cases with really
<a name="l123"></a>big, sparse ranges.
<a name="l124"></a>
<a name="l125"></a>* Allows ranges like "</span><span class=cF2>case 4...7:</span><span class=cF0>" in </span><span class=cF2>switch</span><span class=cF0> stmts.
<a name="l126"></a>
<a name="l127"></a>* A no case number causes next higher int case in </span><span class=cF2>switch</span><span class=cF0> stmts. See </span><span class=cF4>
<a name="l137"></a> case 10: "Ten\n"; break;
<a name="l138"></a> case: "Eleven\n"; break; //One plus prev case.
<a name="l139"></a> }</span><span class=cF0>
<a name="l140"></a>
<a name="l141"></a>* Switch statements can be nestled with a single switch expression! This is
<a name="l142"></a>known as a "sub_switch" statement. </span><span class=cF2>start</span><span class=cF0>/</span><span class=cF2>end</span><span class=cF0> are used to group cases. Don't
<a name="l143"></a>goto out of, throw an exception out of, or return out of the </span><span class=cF2>start</span><span class=cF0> front porch
<a name="l149"></a> case 0: "Zero "; break;
<a name="l150"></a> case 2: "Two "; break;
<a name="l151"></a> case 4: "Four "; break;
<a name="l152"></a> start:
<a name="l153"></a> "[";
<a name="l154"></a> case 1: "One"; break;
<a name="l155"></a> case 3: "Three";break;
<a name="l156"></a> case 5: "Five"; break;
<a name="l157"></a> end:
<a name="l158"></a> "] ";
<a name="l159"></a> break;
<a name="l160"></a> }</span><span class=cF0>
<a name="l161"></a> OutPut:
<a name="l162"></a> ></span><span class=cF2>Zero [One] Two [Three] Four [Five]</span><span class=cF0>
<a name="l163"></a>
<a name="l164"></a>* A </span><span class=cF2>no_warn</span><span class=cF0> stmt will suppress an unused var warning.
<a name="l165"></a>
<a name="l166"></a>* You can have multiple member vars of a class named "</span><span class=cF2>pad</span><span class=cF0>" or "</span><span class=cF2>reserved</span><span class=cF0>", and it
<a name="l167"></a>won't issue warnings.
<a name="l168"></a>
<a name="l169"></a>* </span><span class=cF2>noreg</span><span class=cF0> or </span><span class=cF2>reg</span><span class=cF0> can be placed before a function local var name. You can,
<a name="l170"></a>optionally, specify a reg after the </span><span class=cF2>reg</span><span class=cF0> keyword.
<a name="l174"></a> //Only use </span><a href="/Wb/Kernel/KernelA.HH#l1804"><span class=cF4>REGG_LOCAL_VARS</span></a><span class=cF2> or </span><a href="/Wb/Kernel/KernelA.HH#l1805"><span class=cF4>REGG_LOCAL_NON_PTR_VARS</span></a><span class=cF2> for reg vars or else
<a name="l193"></a>* A single quote can encompass multiple characters. </span><span class=cF2>'ABC'</span><span class=cF0> is equ to </span><span class=cF2>0x434241</span><span class=cF0>. </span><span class=cF4>
<a name="l229"></a>* You can use </span><a href="/Wb/Compiler/CMisc.HC#l1"><span class=cF4>Option</span></a><span class=cF0>(</span><a href="/Wb/Kernel/KernelA.HH#l1549"><span class=cF4>OPTf_WARN_PAREN</span></a><span class=cF0>,ON) to find unnecessary parentheses in
<a name="l232"></a>* You can use </span><a href="/Wb/Compiler/CMisc.HC#l1"><span class=cF4>Option</span></a><span class=cF0>(</span><a href="/Wb/Kernel/KernelA.HH#l1550"><span class=cF4>OPTf_WARN_DUP_TYPES</span></a><span class=cF0>,ON) to find dup local var type stmts.
<a name="l235"></a>text into the stream of code being compiled. See </span><a href="/Wb/Kernel/KMain.HC#l16"><span class=cF4>#exe {}</span></a><span class=cF0> for an example where
<a name="l237"></a>program. </span><a href="/Wb/Compiler/CMisc.HC#l68"><span class=cF4>StreamPrint</span></a><span class=cF0>() places text into a src program stream following the
<a name="l238"></a>conclusion of the </span><span class=cF2>#exe{}</span><span class=cF0> blk.
<a name="l239"></a>
<a name="l240"></a>* No </span><span class=cF2>#define</span><span class=cF0> functions exist (I'm not a fan)
<a name="l241"></a>
<a name="l242"></a>* No </span><span class=cF2>typedef</span><span class=cF0>, use </span><span class=cF2>class</span><span class=cF0>.
<a name="l243"></a>
<a name="l244"></a>* No type-checking
<a name="l245"></a>
<a name="l246"></a>* Can't use </span><span class=cF2><></span><span class=cF0> with </span><span class=cF2>#include</span><span class=cF0>, use </span><span class=cF2>""</span><span class=cF0>.
<a name="l247"></a>
<a name="l248"></a>* "</span><span class=cF2>$</span><span class=cF0>" is an escape character. Two dollar signs signify an ordinary $. See </span><span class=cF4>
<a name="l249"></a></span><a href="/Wb/Doc/DolDocOverview.DD.HTML#l1"><span class=cF4>DolDoc</span></a><span class=cF0>. In </span><span class=cF2>asm</span><span class=cF0> or </span><a href="/Wb/Doc/HolyC.DD.HTML#l1"><span class=cF4>HolyC</span></a><span class=cF0> code, it also refers to the inst's address or the
<a name="l250"></a>offset in a </span><span class=cF2>class</span><span class=cF0> definition.
<a name="l251"></a>
<a name="l252"></a>* </span><span class=cF2>union</span><span class=cF0> is more like a class, so you don't reference it with a </span><span class=cF2>union</span><span class=cF0> label after
<a name="l253"></a>you define it. Some common unions are declared in </span><a href="/Wb/Kernel/KernelA.HH#l67"><span class=cF4>KernelA.HH</span></a><span class=cF0> for 1,2,4 and 8
<a name="l255"></a>type when used by itself. See </span><a href="/Wb/Demo/SubIntAccess.HC#l1"><span class=cF4>::/Demo/SubIntAccess.HC</span></a><span class=cF0>.
<a name="l257"></a>* </span><span class=cF2>class</span><span class=cF0> member vars can have meta data. </span><span class=cF2>format</span><span class=cF0> and </span><span class=cF2>data</span><span class=cF0> are two meta data types
<a name="l258"></a>now used. All compiler structures are saved and you can access the compiler's
<a name="l259"></a>info about classes and vars. See </span><a href="/Wb/Demo/ClassMeta.HC#l1"><span class=cF4>::/Demo/ClassMeta.HC</span></a><span class=cF0> and </span><a href="/Wb/Adam/DolDoc/DocForm.HC#l209"><span class=cF4>DocForm</span></a><span class=cF0>().
<a name="l265"></a>* See </span><a href="/Wb/Demo/Exceptions.HC#l1"><span class=cF4>::/Demo/Exceptions.HC</span></a><span class=cF0>. </span><span class=cF2>try{} catch{}</span><span class=cF0> and </span><span class=cF2>throw</span><span class=cF0> are different from C++. </span><span class=cF2>th
<a name="l266"></a>row</span><span class=cF0> is a function with an 8-byte or less char arg. The char string passed in </span><span class=cF2>th
<a name="l267"></a>row()</span><span class=cF0> can be accessed from within a </span><span class=cF2>catch{}</span><span class=cF0> using the </span><span class=cF2>Fs->except_ch</span><span class=cF0>. Within a </span><span class=cF2>c
<a name="l268"></a>atch {}</span><span class=cF0> blk, set the var </span><span class=cF2>Fs->catch_except</span><span class=cF0> to </span><span class=cF2>TRUE</span><span class=cF0> if you want to terminate the
<a name="l269"></a>search for a hndlr. Use </span><a href="/Wb/Kernel/KExcept.HC#l45"><span class=cF4>PutExcept</span></a><span class=cF0>() as a hndlr, if you like.
<a name="l271"></a>* A function is available similar to </span><span class=cF2>sizeof</span><span class=cF0> which provides the offset of a
<a name="l272"></a>member of a class. It's called </span><span class=cF2>offset</span><span class=cF0>. You place the class name and member
<a name="l273"></a>inside as in </span><span class=cF2>offset(classname.membername)</span><span class=cF0>. It has nothing to do with 16-bit
<a name="l274"></a>code. Both </span><span class=cF2>sizeof</span><span class=cF0> and </span><span class=cF2>offset</span><span class=cF0> only accept one level of member vars. That is,
<a name="l275"></a>you can't do </span><span class=cF2>sizeof(classname.membername.submembername)</span><span class=cF0>.
<a name="l276"></a>
<a name="l277"></a>* There is no </span><span class=cF2>continue</span><span class=cF0> stmt. Use </span><span class=cF2>goto</span><span class=cF0>.
<a name="l278"></a>
<a name="l279"></a>* </span><span class=cF2>lock{}</span><span class=cF0> can be used to apply asm </span><span class=cF2>LOCK</span><span class=cF0> prefixes to code for safe multicore
<a name="l280"></a>read-modify-write accesses. The code bracked with have </span><span class=cF2>LOCK</span><span class=cF0> asm prefix's
<a name="l281"></a>applied to relevant insts within. It's a little shoddy. See </span><span class=cF4>
<a name="l284"></a>* There is a function called </span><a href="/Wb/Kernel/Mem/MAllocFree.HC#l384"><span class=cF4>MSize</span></a><span class=cF0>() which gives the size of an object alloced
<a name="l289"></a>* You CAN </span><a href="/Wb/Kernel/Mem/MAllocFree.HC#l383"><span class=cF4>Free</span></a><span class=cF0>() a </span><span class=cF2>NULL</span><span class=cF0> ptr. Useful variants of </span><a href="/Wb/Kernel/Mem/MAllocFree.HC#l387"><span class=cF4>MAlloc</span></a><span class=cF0>() can be found </span><a href="/Wb/Kernel/Mem/MAllocFree.HC#l395"><span class=cF4>Here</span></a><span class=cF0>.
<a name="l290"></a>Each task has a heap and you can </span><span class=cF2>MAlloc</span><span class=cF0> and </span><span class=cF2>Free</span><span class=cF0> off-of other task's heaps, or
<a name="l291"></a>make an independent heap with </span><a href="/Wb/Kernel/Mem/HeapCtrl.HC#l1"><span class=cF4>HeapCtrlInit</span></a><span class=cF0>(). See </span><a href="/Wb/Adam/Opt/Utils/HeapLog.HC#l73"><span class=cF4>HeapLog</span></a><span class=cF0>() for an example.
<a name="l294"></a>large local vars from the heap. You can change </span><a href="/Wb/Kernel/KernelA.HH#l2843"><span class=cF4>MEM_DFT_STK</span></a><span class=cF0> and recompile </span><span class=cF2>Kernel</span><span class=cF0>
<a name="l295"></a>or request more when doing a </span><a href="/Wb/Kernel/KTask.HC#l242"><span class=cF4>Spawn</span></a><span class=cF0>(). You can use </span><a href="/Wb/Kernel/KTask.HC#l110"><span class=cF4>CallStkGrow</span></a><span class=cF0>(), but it's odd.
<a name="l300"></a>* </span><span class=cF2>printf()</span><span class=cF0> has new codes. See </span><a href="/Wb/Doc/Print.DD.HTML#l1"><span class=cF4>Print("") Fmt Strings</span></a><span class=cF0>.