From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Still can't get DJGPP working... Date: Mon, 27 Jan 1997 19:10:11 -0800 Organization: Two pounds of chaos and a pinch of salt Lines: 120 Message-ID: <32ED6E13.3C58@cs.com> References: <199701272114 DOT VAA16080 AT easynet DOT co DOT uk> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp211.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Robert J. Baker wrote: > > C:\~rbaker\cgi>gcc -o !bg.exe !bg.c > !bg.c: In function `Main': > !bg.c:239: warning: assignment discards `const' from pointer target type > !bg.c:240: warning: assignment discards `const' from pointer target type These warnings occur because whatever function you are calling has a const char * return type and you are trying to assign it to a char * pointer. gcc warns about this because you can use that char * pointer to modify the data, which negates the 'const' qualifier. To fix this warning, you should do one of two things. First, though, look up the function you are using to make sure that it's safe to modify the data at the location of the returned pointer! Then, you can either define the variable you assign it to as const, or typecast the returned pointer to (char *). This may sound a bit confusing, so I'll use an example: const char *grok( const char *s1 ); int main( void ) { char *p; p = grok( "This is a test string" ); return 0; } Here, the const qualifier on grok()'s return type indicates that you should NOT attempt to modify the returned string. Yet you are assigning the return value to a normal pointer. If you know that you won't need to modify the string, then you should do the following: const char *p; p = grok( "This is a test string" ); If you know that what you are doing is safe, or if putting a 'const' qualifier on all the variables associated with the string would be too much of a pain, then you can do this: char *p; p = (char *) grok( "This is a test string" ); Typecasting explicitly tells gcc not to worry about the 'const' qualifier. > !bg.c(.text+0xf8): undefined reference to `va_start' > !bg.c(.text+0x123): undefined reference to `va_end' > > I'm not sure I understand the warnings, but the errors turned out to > be due to my assuming that including "stdio.h" automatically causes > "stdarg.h" to be included as well, as is the case with Turbo C 1.5 > -- are there any other differences I should beware of? If you get any undefined references, you need to look in the libc docs for the library functions that you use to confirm what header file(s) they are in. There are a lot of differences between Turbo C and DJGPP, simply because one is a purebred DOS product and the other is derived from Unix GCC. They use somewhat different standards. BTW, the documentation for the va_list-related functions was accidentally omitted from the libc docs for DJGPP v2. I've submitted this as a bug report; in the meantime you can look up 'vfprintf' in the docs to see an example. If you start to get into assembly language, interrupt handling, and/or direct hardware interface (graphics, etc.), you'll discover that there are a LOT of differences between a 16-bit real mode compiler and a 32-bit protected mode compiler. This isn't just DJGPP here; it's the difference between two generations of programming. See below for more info. > Indeed (and this is the main reason for this post) are there any > instructions of any kind with djgpp, where do I look for them, and do > I need anything special to view them? Also, is there a good book on > this compiler available, either specific or covering how an > ANSI-standard Unix-alike compiler (as I presume this one is) should > behave, what functions are available, how to write makefiles, etc.? Every DJGPP package comes with complete instructions and documentation; you just need the right program to view them. The GNU documentation is in Info format, which can be read with the Info hypertext browser contained in the 'v2gnu/txi390b.zip' package. Once you have installed Info, simply type "info" to begin reading the docs. If you are having trouble with Info's commands, press 'h' to start the mini-tutorial. There is no book available yet for DJGPP. However, the DJGPP Book Project (at www2.ari.net/flyboy/) is currently underway as an attempt to compile the experience of all the DJGPP users into a single easy to use reference work. I myself am writing a chapter, in fact. :) > Finally, could someone give (or point me towards) a guide as to what > the various components actually are, so that I may delete those I > don't need (do I really need the "zoneinfo" directory, for example?), > as the full install takes up about 90Mb of disk space? There are two guides that are useful above all others: the 'readme.1st' file that accompanies the DJGPP distribution, and the DJGPP Frequently Asked Questions list. The FAQ is perhaps the most comprehensive guide to all the various difficulties beginning (and advanced) users encounter when switching from other compilers to DJGPP. It covers everything from installation to compilation to graphics and interrupt programming. The FAQ's binary distribution (v2/faq210b.zip from SimTel) comes in Info, text, and HTML formats. You can also read it online at http://www.delorie.com/djgpp/v2faq/. Hope this helps! -- John M. Aldrich, aka Fighteer I -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS d- s+:- a-->? c++>$ U@>++$ p>+ L>++ E>++ W++ N++ o+>++ K? w(---) O- M-- V? PS+ PE Y+ PGP- t+(-) 5- X- R+(++) tv+() b+++ DI++ D++ G>++ e(*)>++++ h!() !r !y+() ------END GEEK CODE BLOCK------