X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=+Xtnffxfmmw7VxfCmIH22Z4AZyHinmXYUkRcHr53whU=; b=fyt0OmqaYLfOvoXbxfDGAw4r6NV3oiwwrY2eDVvbTv+NqAoHMV3zvq16bPYe7eD30O kdWfrWvOq5R57CqQd2H8NmKSDAVr10+9XAMDNM+WwAbG2Liu9NRMlRf0NtiuPxd7s1OA POdGrXytb6Rz2aH2d8t41G09Tillvp3usKn1tdCF5VHD7N6APkfRv6G14CuAfc25RaF9 dBjciYJzGkoiNGnF//rUK+4B04EQQnb0CDzpIj39Nao2iJLOIWyldnjXHKEN+5bNseqW zB/5LfuvY8eaeVUDHjZQAw2prP2TX8Zi3B7DP5mDOtNGMdmZm7q/rSgF57Z68IpbaKKK t6fQ== MIME-Version: 1.0 In-Reply-To: <17d4b525-2c31-4c20-b3c5-a7118343e9a5@googlegroups.com> References: <17d4b525-2c31-4c20-b3c5-a7118343e9a5 AT googlegroups DOT com> Date: Fri, 20 Jul 2012 08:33:31 +0300 Message-ID: Subject: Re: Upgrading from a bad C compiler From: Ozkan Sezer To: djgpp AT delorie DOT com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id q6K5xL5k031510 Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Fri, Jul 20, 2012 at 5:16 AM, K.J.Williams wrote: > I recently upgraded, and imported some source code from a non-standard ANSI C compliant compiler (Borland Turbo C++ 3.0 for DOS) to DJGPP because of the memory limitation and the fact that TC++ far invention for accessing memory does not work. Now I am using DJGPP via RHIDE get over this disadvantage of memory, and I am running into a lot of compiler (syntax) errors because the old compiler I used was not compliant. The only difference between RHIDE and Turbo C++ that I have noticed, is that there is no verbose explanation of the errors - which I could access in TC++. Is there a documentation where I can find out more in depth what these errors mean? > > 3 examples of errors - simplified (2 of which I solved)- things that I could do in C in TC++ that DJGPP compiler nails me on : > > #1 > > //in myfile1.c > > short int myfunc(char x) > { > char w[0] = x;// legal in TC++ - but illegal in DJGPP, to assign the address > // of x to w[0] in this manner > .... > .... > return 0; > } > > the fix: > > char w[0] = &x; Hopefully correct but possibly more detail needed to be sure > > #2 > > #define WIDGETS 200 > > //in myfile2.c - a global struct > > struct mystuff > { > .... > .... > }; > > struct mystuff *mything = NULL; //for use with malloc() & free() > > short int badstuff = 0; > > short int myfunc(void) > { > short unsigned int x; > .... > x = sizeof(mystuff)*WIDGETS; //legal in TC++ but illegal in DJGPP > .... > return 0; > } > > > the fix: > > x = sizeof(mything)*WIDGETS; // I don't understand why "mystuff" > > //doesn't work instead of using mything... This is a wrong fix: sizeof(mything) means sizeof(PTR *) you need sizeof(struct mystuff) > > #3 > > //in myfile3.c , declares two extern of two variables in myfile2.c outside before any function //bodies > > // first extern: > > extern short int badstuff = 0;//legal in TC++ but illegal in DJGPP > > // the fix is : extern short int badstuff;// but I dont understand why > because you simply declare its type and existence by the extern, its initialization can't be done by the extern declaration, should be done at the place where the real variable is > // second extern: > > extern struct mystuff *mything;//legal in TC++ but illegal in DJGPP > > extern mystuff *mything;//doesnt work becuase the compiler doesn't know what mystuff is > extern struct mystuff;//doesnt work becuase mystuff is a struct template, not a instantiation > extern mything;//doesnt work becuase it doesnt know what type mything is, and even so... > > //... mything is a variable not a pointer to a struct of mystuff which is what I am trying to > //get recognized in myfile3.c > > //THIS IS WHERE I AM STUCK extern struct mystuff *mything; simply compiles with my djgpp cross-compiler (and by any other gcc), don't know what's going on here > > //please note on some download sites, TC++ is available - even though its obsolete and > //non-standard ANSI compliant, it should never be used. I have it as the product that > //came in a box with the books and etc. mediums to install it. > > > Thanks In Advance, > > KJ > -- O.S.