#re: help w/C++
7 messages in this thread
I would like some help compiling a basic C++ program using SASC 6.51
#include <iostream.h>
void main() {
cout << "Hello World"; }
The errors are in iostream.h (but I also get similar errors in new.h). starting
with line 29, I get an error 57 (semi-colon expected) for the next 3 lines.
struct streampos also has numerous errors, one of which is that the program
feels that it is a function. I don't know how to fix these problems, and would
appreciate any help.
SAS C 6.51 expects C++ programs to be in filenames that end in .cxx and
files ending in .c to contain only C code. I could only duplicate the
errors you describe by putting your C++ code in a file called hello.c, as
hello.cxx it compiled OK.
Peter Wade
Autopiloting from London, England
If you don't want to rename your file, use the CXXSRC option on the SC
command to force SC to treat your file as a C++ source file.
If you don't tell it explicitly what file type a given file is, SC makes its
best guess. You can use the CSRC, CXXSRC, ASM, and LIB keywords to force SC
to treat files certain ways.
This is all covered in the User's Guide; I suggest you browse through the
SC command line description before you get much further.
–Doug
BTW: Thanks for your help. That was the problem, not ending in .cxx. I am
learning. I found out that there will be one more upgrade to SASC before the
end of the year. The SAS rep told me.
I am wondering if you could help me with a different problem, now. I have a
5M A2000 w/33 MHz '030, WB 1.3 (That will change in the spring), but I tend to
run out of memory, if the program does too much. The problem seems to be the
regular includes. Is there anyway to get the tranlator to use the HD for
additional memory? It seems there is supposed to be, by what the manual says,
but I can't do it.
I am curious, as my modules are very specialized right now, and it is
difficult to keep this up. Thanx.
There is a compiler option called "MemorySize". You are supposed to use
this to tell it how much memory you have. It can be set to tiny, small,
medium, large or huge. It defaults to large. I haven't experimented with
this, the manual says that larger settings allow the compiler to handle
more complex programs and compile faster. If your programs are very
complex you may need the huge setting rather than more memory. Then again
if it is running out of physical memory it may be worth trying the medium
setting.
On the older versions I believe that the compiler kept some of its
intermediate files in the T: device. This is usually assigned to be in
RAM: by startup-sequece but re-assigning it to a directory on the hard
disc freed up some memory, at the expense of slower compilation. I don't
know if this works on 6.51.
I have not done anything in C++ yet apart from trying a few simple
examples. I am still trying to learn C++ from books. My current project is
in C. I am getting by with a total of 4MBytes of memory and a standard
68000. My accelerator that gave me a 40MHz 68030 and 6MBytes total memory
is now gone (it was on its way back to be repaired when it was lost in the
post!). I'm hoping to get a replacement at the next Amiga show but
accelerators for the 500+ are not very common these days.
I have heard that SAS intend to put together a final bug fix update before
all work on the Amiga compiler stops. They haven't said what it will be
called, but the 6.52 update is a fake so avoid it.
Peter Wade
Autopiloting from London, England
Thanx for your help. I set my memory size to tiny, hoping that it would
help, but to no avail. I will just fax this to SAS. 🙁
Yes, they will do one more upgrade. If you want a good help in programming
in C++ look for a file called I++_10.lzh. It is useful as it has some
intuition classes that are neat. I prefer it over A++. I am adding to it, and
will see if the author lets me post it.
Thanx for all your help, and good luck.
The last word on SAS/C and SAS/C++ memory usage:
The MEMORYSIZE option will help if you're compiling C code, but the C++
translator doesn't honor it, unfortunately. The C++ translator DOES use T:
for the intermediate C source file, so you can save memory by assigning T: to
the hard drive. If you still run out of memory, there's nothing more we can
do at that point. The C++ translator does take a substantial amount of
memory, unfortunately, and the C++ library headers take up lots of memory as
well. You can decrease memory usage and improve speed by reducing the number
of inline functions you define in your header files.
The C compiler proper never uses T:, but it does use the directory
containing the target .o file for a couple of intermediate files. Make sure
the target .o file isn't in RAM. The LIST, XREF, OPTIMIZEGLOBAL, and
DEBUG=SYMBOL or higher options all take extra memory. GST may take more
memory if you stick everything but the kitchen sink in the GST file; if you
limit the GST file to only the headers that you actually use, it should take
about the same amount of memory as a normal compilation, but it will fragment
memory less. Of course, GSTs are useless with C++ source files.
–Doug