mirror of
https://github.com/ENSL/NS.git
synced 2024-12-11 05:11:27 +00:00
7b18f64309
git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@16 67975925-1194-0748-b3d5-c16f83f1a3a1
132 lines
No EOL
9 KiB
HTML
132 lines
No EOL
9 KiB
HTML
<html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>STLport: Note for IBM OS/390 C/C++ Users</title><link href="doc.css" type="text/css" rel="stylesheet"></head><body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" vlink="#314A30" link="#314A30" text="black" bgcolor="white"><table border="0" cellspacing="0" cellpadding="0"><tr valign="top" align="left"><td width="24"><img src="images/trans.gif" border="0" height="1" width="24"></td><td width="776"><img border="0" height="14" width="1" src="images/trans.gif"><br><a href="../index.html"><img src="images/stl_logo_doc.gif" border="0" height="80" width="80"></a><a href="http://www.stlport.com"><img border="0" height="80" width="461" src="images/t_doc2.gif"></a><br><img src="images/trans.gif" border="0" height="24" width="1"><br><img src="images/black.gif" border="0" height="1" width="776"><br><img src="images/trans.gif" border="0" height="24" width="1"></td></tr><tr valign="top" align="left"><td width="24"><img src="images/trans.gif" border="0" height="1" width="24"></td><td width="776"><img src="images/trans.gif" border="0" height="10" width="776"></td></tr><tr valign="top" align="left"><td width="24"><img src="images/trans.gif" border="0" height="1" width="24"></td><td width="776">
|
|
|
|
<span class="heading">Note for IBM OS/390 C/C++ Users</span>
|
|
<p> </p>
|
|
<hr>
|
|
<br>
|
|
<b><i><font face="Arial,Helvetica,Geneva"><font size="+1">Known Problems</font></font></i></b>
|
|
<p><b>Compiling:</b></p>
|
|
<ol>
|
|
<li>OS/390 C/C++ requires explicit template notation such as
|
|
template_class<Param> where most other conformant compilers
|
|
only accept template_class (inside template method bodies, etc.):</li>
|
|
<p><br>
|
|
<br>
|
|
<font size="+0"> template <class Param> class
|
|
template_class {<br>
|
|
<br>
|
|
template_class foo();
|
|
// error for OS390 C/C++<br>
|
|
<br>
|
|
template_class<Param> foo();
|
|
// OK<br>
|
|
<br>
|
|
...<br>
|
|
<br>
|
|
};</font></p>
|
|
This adaptation works around the above OS/390 C/C++ requirement, but
|
|
may cause compatibility problems when porting template code from other
|
|
platforms.
|
|
<li>OS/390 C++, does not allow passing an extern "C"
|
|
function pointer as an argument to a C++ function. For example:</li>
|
|
<p><br>
|
|
<br>
|
|
<font size="+0"> template <class Result> <br>
|
|
<br>
|
|
pointer_to_void_function<Result>
|
|
ptr_gen(Result (*x)());<br>
|
|
<br>
|
|
<br>
|
|
<br>
|
|
p = ptr_gen(rand); // error for OS/390 C/C++</font></p>
|
|
In the above template, <i>ptr_gen</i> takes a function pointer as its
|
|
argument and returns a function pointer adaptor (a type of function
|
|
object), and <i>rand</i> is an extern "C" library pointer.
|
|
This is not allowed because C and C++ linkage is different on OS/390
|
|
C/C++.
|
|
<p>To work around this problem, provide a C++ wrapper around the
|
|
extern "C" function and pass the C++ wrapper instead:</p>
|
|
<p><br>
|
|
<br>
|
|
<font size="+0"> int cxxrand(void) { return rand();}<br>
|
|
<br>
|
|
p = ptr_gen(cxxrand);
|
|
// OK</font></p>
|
|
<li>OS/390 C++ does not allow functions to be declared with a function
|
|
or an array as its return type:</li>
|
|
<p><br>
|
|
<br>
|
|
<font size="+0"> template <class InputIterator, class
|
|
OutputIterator,class result)<br>
|
|
<br>
|
|
OutputIterator
|
|
adjacent_difference(InputIterator first, <br>
|
|
<br>
|
|
InputIterator
|
|
last, <br>
|
|
<br>
|
|
OutputIterator
|
|
result);<br>
|
|
<br>
|
|
<br>
|
|
<br>
|
|
main() {<br>
|
|
<br>
|
|
int number[10];<br>
|
|
<br>
|
|
int different[5];<br>
|
|
<br>
|
|
adjacent_difference(number,<br>
|
|
<br>
|
|
number
|
|
+ 5,<br>
|
|
<br>
|
|
different);
|
|
// error for OS/390 C/C++<br>
|
|
<br>
|
|
}</font></p>
|
|
In the above example, the compiler attempts to create an instantiation
|
|
that returns an array <i>int[]</i>, which is not allowed in OS/390
|
|
C/C++:
|
|
<p><br>
|
|
<br>
|
|
<font size="+0"> int[] adjacent_difference(int*, int*, int*)</font></p>
|
|
To work around this problem, cast the <i>int</i> array to pointer to <i>int</i>:
|
|
<p><br>
|
|
<br>
|
|
<font size="+0"> adjacent_difference(number,number + 5, (int *)
|
|
different); // OK</font></p>
|
|
</ol>
|
|
<b>Linking:</b>
|
|
<p>Repository handling in the compiler is imperfect, so you may
|
|
experience various problems during the link step. The problems are
|
|
generally of two kinds: duplicate symbols or unresolved symbols. The
|
|
duplicate symbol problem is not fatal, since the symbols are weak
|
|
(compiler generated) in that case. When it comes to large projects,
|
|
however, it may cause unacceptable code bloat (extra code generated by
|
|
the compiler when it separates the template instantiation files into the
|
|
TEMPINC directory). To overcome this problem, this adaptation simulates <i>separate
|
|
template implementation</i>. Compiling templates using the tempinc
|
|
compile option, minimizes code bloat as there are less duplicate
|
|
symbols. The problem with undefined symbols is also caused by imperfect
|
|
repository handling, but may require manual intervention. The general
|
|
rule is: <b>if you get <i>unresolved symbol</i> errors, explicit
|
|
instantiation will most likely help</b>. For example:</p>
|
|
<p><i>Unresolved:</i></p>
|
|
<p><br>
|
|
<br>
|
|
<font size="+0"> __default_alloc_template<0,0>::allocate(unsigned
|
|
long)<br>
|
|
<br>
|
|
__default_alloc_template<0,0>::deallocate(void *, unsigned
|
|
long)</font></p>
|
|
To work around this problem, just instantiate __default_alloc_template<0,0>
|
|
explicitly in a module:
|
|
<p><br>
|
|
<br>
|
|
<font size="+0"> template class __default_alloc_template<0,0>;</font></p>
|
|
<h2><font size="+0">Useful Links</font></h2>
|
|
<p><font size="+0">Check out :</font></p>
|
|
<p><a href="http://www.software.ibm.com/ad/c390/cmvsstlp.htm">http://www.software.ibm.com/ad/c390/cmvsstlp.htm</a></p>
|
|
|
|
</td></tr><tr valign="top" align="left"><td width="24"><img src="images/trans.gif" border="0" height="1" width="24"></td><td width="776"><img src="images/trans.gif" border="0" height="20" width="50"><br><a href="index.html">Table of Contents</a><br></td></tr><tr valign="top" align="left"><td width="24"><img src="images/trans.gif" border="0" height="1" width="24"></td><td width="776"><img src="images/trans.gif" border="0" height="40" width="80"><br><img src="images/black.gif" border="0" height="1" width="776"></td></tr><tr valign="top" align="left"><td width="24"><img src="images/trans.gif" border="0" height="1" width="24"></td><td width="776"><img src="images/black.gif" border="0" height="1" width="776"></td></tr><tr valign="top" align="left"><td width="24"><img src="images/trans.gif" border="0" height="1" width="24"></td><td width="776"><img src="images/trans.gif" border="0" height="5" width="50"><br><span class="copyright">Copyright 2001 by STLport</span><br><img src="images/trans.gif" border="0" height="50" width="80"></td></tr></table></body></html> |