<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://tech-pubs.net/wiki/index.php?action=history&amp;feed=atom&amp;title=MIPSPro</id>
	<title>MIPSPro - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://tech-pubs.net/wiki/index.php?action=history&amp;feed=atom&amp;title=MIPSPro"/>
	<link rel="alternate" type="text/html" href="https://tech-pubs.net/wiki/index.php?title=MIPSPro&amp;action=history"/>
	<updated>2026-04-23T14:21:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://tech-pubs.net/wiki/index.php?title=MIPSPro&amp;diff=335&amp;oldid=prev</id>
		<title>Raion at 15:45, 3 October 2025</title>
		<link rel="alternate" type="text/html" href="https://tech-pubs.net/wiki/index.php?title=MIPSPro&amp;diff=335&amp;oldid=prev"/>
		<updated>2025-10-03T15:45:45Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:45, 3 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l288&quot;&gt;Line 288:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 288:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This example produces two object files, foo.o and bar.o, and links them with the default C library, libc , to produce an executable called a.out.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This example produces two object files, foo.o and bar.o, and links them with the default C library, libc , to produce an executable called a.out.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== Works Cited ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Raion</name></author>
	</entry>
	<entry>
		<id>https://tech-pubs.net/wiki/index.php?title=MIPSPro&amp;diff=334&amp;oldid=prev</id>
		<title>Raion at 15:45, 3 October 2025</title>
		<link rel="alternate" type="text/html" href="https://tech-pubs.net/wiki/index.php?title=MIPSPro&amp;diff=334&amp;oldid=prev"/>
		<updated>2025-10-03T15:45:20Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:45, 3 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l97&quot;&gt;Line 97:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 97:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==== String Literals ====&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==== String Literals ====&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;IRIXNet staff Dexter1 helpfully pointed this out in a forum post:&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Shorthand initialization of char a[] = &quot; &quot;; with MIPSpro will go wrong with leading zero bytes. Rewrite that code.&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;ref&amp;gt;https://forums.irixnet.org/thread&lt;/ins&gt;-&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;581.html&amp;lt;/ref&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Shorthand initialization of char a[] = &quot; &quot;; with MIPSpro will go wrong with leading zero bytes. Rewrite that code.&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;What follows is his example copied mostly&lt;/del&gt;-&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;verbatim:&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  #include &amp;lt;stdio.h&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  #include &amp;lt;stdio.h&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Raion</name></author>
	</entry>
	<entry>
		<id>https://tech-pubs.net/wiki/index.php?title=MIPSPro&amp;diff=57&amp;oldid=prev</id>
		<title>Raion: Created page with &quot;MIPSPro is the IRIX-native C/C++/FORTRAN compiler that was distributed by SGI for use in IRIX development.  This page serves to document MIPSPro&#039;s behavior, characteristics, compatibility, and differences from other UNIX-style cc compilers and the GNU Compiler Collection.  For legacy MIPSPro releases and documentation, see IRIS Development Option for more info.  == General == MIPSPro is not installed in a standard IRIX install and requires a collection of other discs...&quot;</title>
		<link rel="alternate" type="text/html" href="https://tech-pubs.net/wiki/index.php?title=MIPSPro&amp;diff=57&amp;oldid=prev"/>
		<updated>2025-09-18T02:53:23Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;MIPSPro is the IRIX-native C/C++/FORTRAN compiler that was distributed by SGI for use in IRIX development.  This page serves to document MIPSPro&amp;#039;s behavior, characteristics, compatibility, and differences from other UNIX-style cc compilers and the GNU Compiler Collection.  For legacy MIPSPro releases and documentation, see &lt;a href=&quot;/wiki/index.php/IRIS_Development_Option&quot; title=&quot;IRIS Development Option&quot;&gt;IRIS Development Option&lt;/a&gt; for more info.  == General == MIPSPro is not installed in a standard IRIX install and requires a collection of other discs...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;MIPSPro is the IRIX-native C/C++/FORTRAN compiler that was distributed by SGI for use in IRIX development.&lt;br /&gt;
&lt;br /&gt;
This page serves to document MIPSPro&amp;#039;s behavior, characteristics, compatibility, and differences from other UNIX-style cc compilers and the GNU Compiler Collection.&lt;br /&gt;
&lt;br /&gt;
For legacy MIPSPro releases and documentation, see [[IRIS Development Option]] for more info.&lt;br /&gt;
&lt;br /&gt;
== General ==&lt;br /&gt;
MIPSPro is not installed in a standard IRIX install and requires a collection of other discs that contain the compiler, development libraries/header files, toolchain and supporting utilities.&lt;br /&gt;
&lt;br /&gt;
MIPSPro supports three ABIs, O32, N32 and N64 (Not to be confused with the Nintendo 64). The O32 ABI is the MIPSII 32-bit ABI, and stands for Old 32. The N32 ABI is analogous to the Intel x32 ABI used on x64 systems to provide enhancements to 32-bit programs through using 32-bit pointers while offering many of the N64 ABI enhancements over O32. The N64 ABI is the native 64-bit ABI for IRIX.&lt;br /&gt;
&lt;br /&gt;
Several compiler front ends were available, including the C, C++ and FORTRAN compilers. Others may have possibly been available at various points historically.&lt;br /&gt;
&lt;br /&gt;
=== Optimization ===&lt;br /&gt;
MIPSPro supports -O0,1,2,3, and fast flags, as well as a number of other optimization/architecture flags:&lt;br /&gt;
&lt;br /&gt;
-mips4 will enable the MIPS IV instruction set&lt;br /&gt;
&lt;br /&gt;
-TARG will enable platform or CPU-specific optimizations&lt;br /&gt;
&lt;br /&gt;
-OPT can tune various optimizations&lt;br /&gt;
&lt;br /&gt;
For a full list, please check: &amp;lt;nowiki&amp;gt;https://irix7.com/techpubs/007-2360-006.pdf&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== TARG flag ===&lt;br /&gt;
The TARG flag controls both platform and CPU specific optimizations and will take a variety of commands:&lt;br /&gt;
&lt;br /&gt;
-TARG:proc=R10000 will, combined with the MIPSIV flag, compile for MIPS IV platforms and enable specific optimizations for the R10000 processors. The resulting binary will run on R5000 and R8000 systems, but will skip the optimizations for those platforms.&lt;br /&gt;
&lt;br /&gt;
-TARG:platform=IP30 will, combined with other flags, enable Octane specific optimizations.&lt;br /&gt;
&lt;br /&gt;
The two commands can be combined as so: -TARG:platform=IP30:proc=R10000 as well as other commands.&lt;br /&gt;
&lt;br /&gt;
=== OPT flag ===&lt;br /&gt;
This has a number of useful flags for more carefully optimizing code.&lt;br /&gt;
&lt;br /&gt;
-OPT:space Optimizes the program for size, similar to the GCC -Os flag&lt;br /&gt;
&lt;br /&gt;
-OPT:Olimit=n This sets a cutoff limit on procedure sizes to optimize. Procedures above the set size will be left alone. The compiler will normally during compilation throw notices out advising of potential ways to tune this.&lt;br /&gt;
&lt;br /&gt;
-OPT:alias=value The compilers must normally be very conservative in optimization of memory references involving pointers (especially in C), since aliases (that is, different ways of accessing the same memory) may be very hard to detect. This option may be used to specify that the program being compiled avoids aliasing in various ways. See the above document for various applications.&lt;br /&gt;
&lt;br /&gt;
=== INLINE flag ===&lt;br /&gt;
Modifies behavior of inlining functions. Inlining can increase performance, but it also requires more memory and thus increases potential cache pressure.&lt;br /&gt;
&lt;br /&gt;
== C Programming with MIPSPro ==&lt;br /&gt;
Much like GCC and other modern compilers, MIPSPro can be called from the commandline like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;% cc foo.c&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where foo.c is a presumably simple test file.&lt;br /&gt;
&lt;br /&gt;
MIPSPro&amp;#039;s ABI, compiling and configuration is via &amp;lt;code&amp;gt;/etc/compiler.defaults&amp;lt;/code&amp;gt;. This can be overridden with compile-time flags, or ENV variables. SGI_ABI, for instance, controls the active ABI:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;% setenv SGI_ABI -n32&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will set it to -n32 mode.&lt;br /&gt;
&lt;br /&gt;
=== Strictness ===&lt;br /&gt;
MIPSPro is far more strict than GCC about accepting standard C code and its compiler infrastructure is entirely different. Common bad programming techniques that work in GCC may not work on MIPSPro, this section aims to document common pitfalls:&lt;br /&gt;
&lt;br /&gt;
==== Variable Attributes ====&lt;br /&gt;
These are not supported, so they have to be patched with #ifdef or removed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;__attribute__(( XXX ))&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is the structure of these.&lt;br /&gt;
&lt;br /&gt;
One variable attribute can be rewritten to work with MIPSPro: the attribute &amp;#039;packed&amp;#039; for a struct can be enforced in MIPSPro by placing the struct between two pragma blocks:&lt;br /&gt;
 #if defined (__sgi)&lt;br /&gt;
 &lt;br /&gt;
 +#pragma pack(1)&lt;br /&gt;
 &lt;br /&gt;
 +#endif&lt;br /&gt;
 &lt;br /&gt;
 struct {&lt;br /&gt;
 &lt;br /&gt;
 ...&lt;br /&gt;
 &lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 #if defined (__sgi)&lt;br /&gt;
 &lt;br /&gt;
 +#pragma pack(0)&lt;br /&gt;
 +#endif&lt;br /&gt;
&lt;br /&gt;
=== Zero Length Arrays ===&lt;br /&gt;
MIPSPro does not support these. Initialize them to a positive number.&lt;br /&gt;
&lt;br /&gt;
=== Variable Length Arrays ===&lt;br /&gt;
Only supported using the c99 driver or -c99.&lt;br /&gt;
&lt;br /&gt;
=== Reserved Keywords ===&lt;br /&gt;
In some programs function names may conflict with keywords in MIPSPro. One such case was caught in Neko Project II for X11 (xnp2) when Raion ported it:&lt;br /&gt;
&lt;br /&gt;
_PIC is a reserved keyword. To fix, change it to __PIC and update all code references. xnp2 patch for reference&lt;br /&gt;
&lt;br /&gt;
==== String Literals ====&lt;br /&gt;
IRIXNet staff Dexter1 helpfully pointed this out in a forum post:&lt;br /&gt;
&lt;br /&gt;
Shorthand initialization of char a[] = &amp;quot; &amp;quot;; with MIPSpro will go wrong with leading zero bytes. Rewrite that code.&lt;br /&gt;
&lt;br /&gt;
What follows is his example copied mostly-verbatim:&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;memory.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 int main(void) {&lt;br /&gt;
 &lt;br /&gt;
 const char a[] = &amp;quot;\0This is a text&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
 const char b[] = { 0x0, &amp;#039;T&amp;#039;, &amp;#039;h&amp;#039;, &amp;#039;i&amp;#039;, &amp;#039;s&amp;#039;, &amp;#039; &amp;#039;, &amp;#039;i&amp;#039;, &amp;#039;s&amp;#039;, &amp;#039; &amp;#039;, &amp;#039;a&amp;#039;,&lt;br /&gt;
 &lt;br /&gt;
 &amp;#039; &amp;#039;, &amp;#039;t&amp;#039;, &amp;#039;e&amp;#039;, &amp;#039;x&amp;#039;, &amp;#039;t&amp;#039;, 0x0 };&lt;br /&gt;
 &lt;br /&gt;
 const char *c = &amp;quot;\0This is a text&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
 char buf1[128];&lt;br /&gt;
 &lt;br /&gt;
 char buf2[128];&lt;br /&gt;
 &lt;br /&gt;
 char buf3[128];&lt;br /&gt;
 &lt;br /&gt;
 size_t lena = sizeof(a) - 1;&lt;br /&gt;
 &lt;br /&gt;
 size_t lenb = sizeof(b) - 1;&lt;br /&gt;
 &lt;br /&gt;
 size_t lenc = 15;&lt;br /&gt;
 &lt;br /&gt;
 memcpy(buf1,a,lena);&lt;br /&gt;
 &lt;br /&gt;
 memcpy(buf2,b,lenb);&lt;br /&gt;
 &lt;br /&gt;
 memcpy(buf3,c,lenc);&lt;br /&gt;
 &lt;br /&gt;
 printf(&amp;quot;length a : %d, length b %d, length c %d\n&amp;quot;, lena, lenb, lenc);&lt;br /&gt;
 &lt;br /&gt;
 printf(&amp;quot;buf11 : %x, buf21 : %x, buf31 : %x\n&amp;quot;, buf11, buf21, buf31);&lt;br /&gt;
 &lt;br /&gt;
 printf(&amp;quot;comparing a with buf1 : %d \n&amp;quot;, memcmp(a,buf1,lena));&lt;br /&gt;
 &lt;br /&gt;
 printf(&amp;quot;comparing b with buf2 : %d \n&amp;quot;, memcmp(b,buf2,lenb));&lt;br /&gt;
 &lt;br /&gt;
 printf(&amp;quot;comparing c with buf3 : %d \n&amp;quot;, memcmp(c,buf3,lenc));&lt;br /&gt;
 &lt;br /&gt;
 printf(&amp;quot;comparing buf1 with buf2 : %d \n&amp;quot;, memcmp(buf1,buf2,lena));&lt;br /&gt;
 &lt;br /&gt;
 printf(&amp;quot;comparing buf1 with buf3 : %d \n&amp;quot;, memcmp(buf1,buf3,lenc));&lt;br /&gt;
 &lt;br /&gt;
 printf(&amp;quot;comparing buf2 with buf3 : %d \n&amp;quot;, memcmp(buf2,buf3,lenb));&lt;br /&gt;
 &lt;br /&gt;
 return 0;&lt;br /&gt;
 }&lt;br /&gt;
Consider this code. The three text containers a, b and c are initialized differently but all should contain &amp;quot;This is a text&amp;quot; preceded and suffixed by a zero byte.&lt;br /&gt;
&lt;br /&gt;
* Container a&amp;#039;s type is an array of char. Its lifetime is limited to the main scope and its initialized content gets put on the stack by the compiler.&lt;br /&gt;
* Container b is the longer version of a and is also typed array of char.&lt;br /&gt;
* Container c is a pointer to a read-only memory block of chars allocated and initialized by the compiler on the heap.&lt;br /&gt;
&lt;br /&gt;
If compiled with MIPSpro cc or c99 and ran, it becomes apparent that array a is not initialized properly. a1 should contain capital &amp;#039;T&amp;#039; but instead it&amp;#039;s a zero byte: once looking at the stack where a is put with a debugger, there is nothing: The preceding zero byte interferes with compiler code and the stack, although it will allocate the correct amount of bytes on the stack, will only contain zeroes.&lt;br /&gt;
&lt;br /&gt;
This &amp;#039;shorthand&amp;#039; initialization of an array is often used in modern opensource software, and is particularly prevalent in test suites, where binary headers and unicode data content are initialized in arrays to test functions.&lt;br /&gt;
&lt;br /&gt;
String Concatenation&lt;br /&gt;
&lt;br /&gt;
GCC will accept the following code, by concatenating the strings:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;puts( &amp;quot;abc&amp;quot; &amp;quot;def&amp;quot; );&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is going to not work on MIPSPro&amp;#039;s c89, but will on c99. A tutorial on how to fix it is below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;puts( &amp;quot;abcdef&amp;quot; );&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can work here, alternatively this would too:&lt;br /&gt;
 char buff[ 255 ];&lt;br /&gt;
 &lt;br /&gt;
 bzero( buff, 0, 255);&lt;br /&gt;
 &lt;br /&gt;
 strcat( buff, &amp;quot;abc&amp;quot; );&lt;br /&gt;
 &lt;br /&gt;
 strcat( buff, &amp;quot;def&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
==== Arithmetic On Pointers ====&lt;br /&gt;
The gcc compiler allows pointer arithmetic on void pointers. For example, gcc allows&lt;br /&gt;
&lt;br /&gt;
void *foo;&lt;br /&gt;
&lt;br /&gt;
foo += 5;&lt;br /&gt;
&lt;br /&gt;
When using MIPSpro, the pointer must be cast to a type with a size:&lt;br /&gt;
&lt;br /&gt;
void *foo;&lt;br /&gt;
&lt;br /&gt;
foo = (char*)foo + 5;&lt;br /&gt;
&lt;br /&gt;
lvalues&lt;br /&gt;
&lt;br /&gt;
gcc allows the use of casts as lvalues. For example:&lt;br /&gt;
&lt;br /&gt;
void *foo;&lt;br /&gt;
&lt;br /&gt;
(char*)foo += 5;&lt;br /&gt;
&lt;br /&gt;
When using MIPSpro, casts cannot be lvalues:&lt;br /&gt;
&lt;br /&gt;
void *foo;&lt;br /&gt;
&lt;br /&gt;
foo = (char*)foo + 5;&lt;br /&gt;
&lt;br /&gt;
=== Block Expressions ===&lt;br /&gt;
gcc allows block expressions, such as ({x++});. When using MIPSPro compilers, remove the extra parentheses.&lt;br /&gt;
&lt;br /&gt;
=== Portable Types ===&lt;br /&gt;
Occasionally code that works on other platforms will compile fine on IRIX, but will misbehave when run. These problems can be difficult to track down, but one thing to check for is assumptions about whether char is signed or unsigned. IRIX compilers default to unsigned. It&amp;#039;s recommended to check for this.&lt;br /&gt;
&lt;br /&gt;
Setting up parallel debugging sessions and stepping through the working and non-working code simultaneously to find where they diverge is often helpful.&lt;br /&gt;
&lt;br /&gt;
Alternatively, try to recompile the code with the MIPSPro option -signed in CFLAGS. This will treat variables with type char as if they are signed char.&lt;br /&gt;
&lt;br /&gt;
setenv() missing in IRIX&lt;br /&gt;
&lt;br /&gt;
Raion&amp;#039;s Libxg library has solved this, see it for an example.&lt;br /&gt;
&lt;br /&gt;
=== POSIX Threads and Reentrancy ===&lt;br /&gt;
The pthread implementation under Irix is mostly the standard pthreads - there is however a caveat in the form of #defines that are necessary.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;CPPFLAGS=&amp;quot;-D_SGI_MP_SOURCE -D_SGI_REENTRANT_FUNCTIONS&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SGI recommended these back when their technical documentation library was a thing - and certainly the first define alters the behavior of the general error indicator errno. Without _SGI_MP_SOURCE individual threads receive separate and unique errno addresses.&lt;br /&gt;
&lt;br /&gt;
If there is unusual behavior regarding threads not sharing or unexpectedly sharing data, one may be missing one of the above.&lt;br /&gt;
&lt;br /&gt;
=== Line terminators ===&lt;br /&gt;
The ANSI specification leaves the determination of valid line terminators to the compiler implementors. MIPSpro allows ^J, while GCC allows both ^J and ^M. The &amp;lt;code&amp;gt;to_unix&amp;lt;/code&amp;gt; command will convert files containing DOS-style ^M line terminators to the UNIX standard ^J form.&lt;br /&gt;
&lt;br /&gt;
=== Pseudo Function Macros ===&lt;br /&gt;
gcc allows the non-standard &amp;lt;code&amp;gt;__FUNCTION__&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__PRETTY_FUNCTION__&amp;lt;/code&amp;gt; pseudo-macros. These are not true macros, so one must use &amp;lt;code&amp;gt;_GNUC__&amp;lt;/code&amp;gt; to test for them. As of IRIX 6.5.18, the c99 func macro is available, which expands to a function name.&lt;br /&gt;
&lt;br /&gt;
=== Extern Inline Functions ===&lt;br /&gt;
The gcc compiler treats extern inline functions as being extern,while the MIPSpro compilers treat them as inline. To get equivalent behavior, remove the inline keyword.&lt;br /&gt;
&lt;br /&gt;
=== Inline defines in C code ===&lt;br /&gt;
Pre-c99 C code often define an INLINE macro being set to &amp;lt;code&amp;gt;inline&amp;lt;/code&amp;gt; MIPSPro cc compiler instead uses &amp;lt;code&amp;gt;__inline&amp;lt;/code&amp;gt; MIPSPro&amp;#039;s c99 compiler follows the c99 standard and will inline function with the &amp;lt;code&amp;gt;inline&amp;lt;/code&amp;gt; keyword.&lt;br /&gt;
&lt;br /&gt;
=== getopt_long() missing in IRIX ===&lt;br /&gt;
Raion had added a compat/getopt.h to libxg&lt;br /&gt;
&lt;br /&gt;
=== Compiler Identification ===&lt;br /&gt;
To pass specific code using an identification macro, the &amp;lt;code&amp;gt;__sgi&amp;lt;/code&amp;gt; macro can be used to reliably define MIPSPro-related code (or IRIX specific code in general, this can be combined with gnu macros to make paths for both gcc and MIPSPro)&lt;br /&gt;
&lt;br /&gt;
=== Warning Sanitizing ===&lt;br /&gt;
MIPSPro is very pedantic with warnings. This can be used in Makefiles to make it less pedantic and behave more like GCC:&lt;br /&gt;
 NOWARN = -woff 1009,1014,1110,1116,1185,1188,1204,1230,1233 \&lt;br /&gt;
 &lt;br /&gt;
 -Wl,-woff,85,-woff,84&lt;br /&gt;
 $(CC) $(NOWARN) ...&lt;br /&gt;
It is highly encouraged to do a normal pass and capture the warnings it gathers anyways, as these can provide some insight into potential mismatches and other issues.&lt;br /&gt;
&lt;br /&gt;
== C99 Specifics ==&lt;br /&gt;
MIPSPro provides C99 compatibility via the c99 driver.&lt;br /&gt;
&lt;br /&gt;
The C99 implementation in MIPSPro is quite good, but unlike standard cc, which is not C99 compliant, it offers far more features:&lt;br /&gt;
&lt;br /&gt;
=== C++-Style Comments ===&lt;br /&gt;
By default, the cc driver does not allow // comments to be used. To use //, either use the c99 driver, or set flag -Xcpluscomm in the CFLAGS.&lt;br /&gt;
&lt;br /&gt;
=== Function Macros ===&lt;br /&gt;
As previously stated, all versions of IRIX since 6.5.18 support the function pseudomacro.&lt;br /&gt;
&lt;br /&gt;
=== Variadic Macros ===&lt;br /&gt;
Unsupported in MIPSPro. A rumor of them being supported seems to have been unfounded. Rewrite them as static inline functions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;https://codeberg.org/IRIXNet-Development/Nekoware-Package-Collections/src/branch/main/patches/neko_libao.patch&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Format problems in printf for variables with size_t and ssize_t ===&lt;br /&gt;
In MIPSPro one cannot use the format strings %zu for size_t types and %zd for ssize_t types. Use %lu and cast both types to unsigned long to print out these variables. Failure to do so will result in unexpected crashes when the program reaches those printf statements.&lt;br /&gt;
&lt;br /&gt;
More to be added as they are discovered.&lt;br /&gt;
&lt;br /&gt;
== Compiler Drivers ==&lt;br /&gt;
The driver commands cc, c99, CC, f90, and f77 call subsystems that compile, optimize, assemble, and link source. This section describes the default behavior for compiler drivers.&lt;br /&gt;
&lt;br /&gt;
At compilation time, it is possible to select one or more options that affect a variety of program development functions, including debugging, profiling, and optimizing. It&amp;#039;s also possible to specify the names assigned to output files. Note that some options have default values that apply if not specified.&lt;br /&gt;
&lt;br /&gt;
When one invokes a compiler driver with source files as arguments, the driver calls other commands that compile the source code into object code. It then optimizes the object code (if requested to do so) and links together the object files, the default libraries, and any other libraries specified.&lt;br /&gt;
&lt;br /&gt;
Given a source file foo.c, the default name for the object file is foo.o. The default name for an executable file is a.out. The following example compiles source files foo.c and bar.c with the default options:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;% cc foo.c bar.c&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example produces two object files, foo.o and bar.o, and links them with the default C library, libc , to produce an executable called a.out.&lt;/div&gt;</summary>
		<author><name>Raion</name></author>
	</entry>
</feed>