Xref: news2.mv.net comp.os.msdos.djgpp:4369 From: nicolas AT dsys DOT ceng DOT cea DOT fr (Eric NICOLAS) Newsgroups: comp.os.msdos.djgpp Subject: Re: Moving from Pascal to Djgpp Date: 29 May 1996 08:33:19 GMT Organization: Commissariat a l'energie atomique, Grenoble (France) Lines: 110 Message-ID: <4oh24f$dhf@news.cea.fr> References: <46251 DOT rkwcvdz AT rivier1 DOT puk DOT ac DOT za> Reply-To: nicolas AT dsys DOT ceng DOT cea DOT fr NNTP-Posting-Host: hudson.ceng.cea.fr To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Hi, Welcome to DJGPP ! First of all, read the FAQ ! It will probably answer to most of questions you have. >[1] File Bloat . Why are the Files Compiled with Djgpp so Bloated . The > Standard Hello world program compiled with Gcc -o Hello.exe Hello.c was > nearly 58k ,and if i used Gcc -s -o Hello.exe hello.c it came down to > 20k.In comparison the same Program in Borland Pascal 7.0 Real mode is > 2.9kb and 8,2kb for Protected mode (with the stub included). Whats the > most effecient way to Compile Small Programs.Also a C++ version is even > more bloated why ? There is a big overhead in every djgpp program which make possible very extended features : 1. Filename globbing : If you have a program "rm" for example whose goal is to destroy all files passed in parameter (ex: "rm a.txt b.txt c.txt"), you can give wildcards in command line, and the startup code included with your executable will expand those wildcards : if you type "rm *.txt", your program will not receive "*.txt" in argv[1], but all files that match *.txt in argv[1], argv[2]. VERY powerfull. 2. Extended environment variables. When your program start, it parses the file DJGPP.ENV and gives you access to all environment variables that are defined in it with standard getenv(). It solves the problem of environment variable space full in command.com program. If you want smaller executables, those functionalities *can* be disabled, but I don't remember how. Isn't it in the FAQ (it should). >[2] Can someone tell me what is wrong with the Following Program fragment I put some comments. Some are errors, some are advices. > #include > > int main(void); > void exit(int); ^ not an error, but don't declare things that are better declared in standard headers. exit() is declared in . You should always include . > int main(void) >{ > int c; > File *fin, *fout; ^ the right data type for files is FILE*, not File*. C and C++ are cAsE sEnSiTiVe :-) > fin = fopen("in.dat", "r"); ^ not really an error, but you should always tell what kind of file you're opening/creating : binary ("rb") or text ("rt"). > if (fin == NULL) { > printf("Unable to open file in.dat\n"); > exit(1); ^ Not an error, but you're in main(), so you can simply use "return 1" to exit the program with a value of 1. It is more elegant than an exit. > } > > fout = fopen("out.dat", "w"); > if (fout == NULL) { > printf("unable to open file out.dat\n"); > exit(2); > } > while ((c=fgetc(fin)) != EOF) { > if (fputc(c, fout) != c) { > printf("Error writing out.dat\n"); > exit(3); > } > } >fclose(fin); >fclose(fout); >return 0; >} >[3] Is there a program to translate Tasm files to Gnu Files. Yes, but TASM assembly must be 32-bit and flat-model. You cannot use segments. Only selectors are valid, and quite difficult to use (call of dpmi functions to create descriptors...). Look in the FAQ. Moreover, Gnu-Assembler is not that difficult. You should move to it. >[4] Does anyone know anything about the Gnu Pascal Compiler Sorry, but I have not written a single Pascal line since I know GNU :-) Good luck with djgpp. -- Eric Nicolas Take a look to the SWORD home page : france: http://bunny.ensea.fr/Pages_Perso/Cedric_Joulain/sword.web/home.html us: http://www.iquest.net/~cworley/sword.web/home.html