Hello,
i've compiled the following code with BCC55.
This Yo proggie has 110KB, how i can compileCode:#include <iostream.h> int main (int argc, char *argv[]) { cout<<"Yo!"; return(0); }
to get smaller exe's.
Hello,
i've compiled the following code with BCC55.
This Yo proggie has 110KB, how i can compileCode:#include <iostream.h> int main (int argc, char *argv[]) { cout<<"Yo!"; return(0); }
to get smaller exe's.
Regards,
Robert
I have never used Borland before but with VC++ you can choose between a Debug or Release compile. If you can do that with Borland then choose Release and that will cut down the file size.
arrh, i got nothing good to say.
http://www.praxis1.vic.edu.au/home/dcola/
The executable (also called on object file) is this large because you are using C++. C++ includes signfigant amounts of unnecessary code in compilations. This is one of the reasons why C++ programs are slower and bulkier.
This is not a fault of C++ itself, it's a fault of all C++ compilers.
That's the diff between Release and Debug? How do you make a Release version? I've always just gone with the default Debug when you compile.
--Garfield
1978 Silver Anniversary Corvette
There is a great deal of difference betwen a release and a debug complie. Also, not all "basic" versions of the current compilers will optimize - that could be your problem.
Sayeh:
No. A modern C++ compiler will optimize code to, at least, as good as a C compiler. The compiler writers know well where the "++ bloat" comes from and do not create object that uses, for example, VFT's. A professional version C++ compiler will produce, (when correctly directed), as slim an .EXE as any C complier with the same source.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
They should generate more or less the same code from the same source, providing the C++ is valid C. However, when using the templatised version of the iostream library (or any template libraries), most compilers seem to generate bloated code due to the way in which they handle templates.A professional version C++ compiler will produce, (when correctly directed), as slim an .EXE as any C complier with the same source.
zen
>> Also, not all "basic" versions of the current compilers will optimize - that could be your problem. <<
I'm on MSVC++6. Shouldn't that be able to make Release? How do you do it? Thanks..
1978 Silver Anniversary Corvette
Garfield;
build -> config's -> release. then it should compile all your files to the release folder, not the debug.
arrh, i got nothing good to say.
http://www.praxis1.vic.edu.au/home/dcola/
Thanks! So you do this when you are done with the program?
1978 Silver Anniversary Corvette
zen:
>>> most compilers seem to generate bloated code due to the way in which they handle templates
Yes, that's true, but if he replaced his cout with a printf then the fact that it is a "++" compiler should not make any difference.
Garfield:
>>> Thanks! So you do this when you are done with the program?
Yes. When compiling for debug, the compiler switches off optimization, and adds some extra code to the .EXE to help you debug. When you are happy with your code, you compile a release version which will be smaller and usually faster.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
>> Yes, that's true, but if he replaced his cout with a printf then the fact that it is a "++" compiler should not make any difference. <<
No, it shouldn't. It all depends on the libraries that are included. Otherwise, it is fine. There are some subtle differences that you can do with C and not C++. C++ hides a little. For instance, memory allocation. C is a little more flexible that C++.
1978 Silver Anniversary Corvette
For example?There are some subtle differences that you can do with C and not C++. C++ hides a little. For instance, memory allocation. C is a little more flexible that C++.
For example the following code:
is perfectly legal in C, but under C++ you'll get a diagnostic message because of the conversion of malloc's void * return to char *.Code:#include <stdlib.h> #include <stdio.h> #include <string.h> int main() { char *p = malloc(1024); if(p) { strcpy(p, "Hello World."); printf("%s\n", p); free(p); } return 0; }
1978 Silver Anniversary Corvette
>>is perfectly legal in C, but under C++ you'll get a diagnostic message because of the conversion of malloc's void * return to char *.
As far as I understand there's a good reason for that. I could only see myself using malloc() in c++ if I didnt know what type of variable I was providing space on the free store for (new and delete are far better and do things like calling constructors and destructors which are essential). How often this would be I dont know, but I doubt it would be good if I found myself in such a position.
Anyway, c++ gives use of newer cast operators like static_cast<T> to try help coders better cope with C style casts which are often a source of error
Yes, but this will have no affect on the code produced by the compiler. It's for compile time checking only.is perfectly legal in C, but under C++ you'll get a diagnostic message because of the conversion of malloc's void * return to char *.
zen