delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/04/06:14:21

From: dontmailme AT iname DOT com (Steamer)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: gdb problem or just silly me - please help
Date: Thu, 04 May 2000 09:53:09 GMT
Organization: always disorganized
Lines: 31
Message-ID: <39114875.5782224@news.freeserve.net>
References: <LLNHJEPGIHPOCAAA AT shared1-mail DOT whowhere DOT com>
NNTP-Posting-Host: modem-32.texas.dialup.pol.co.uk
X-Trace: newsg2.svr.pol.co.uk 957433991 13830 62.137.94.32 (4 May 2000 09:53:11 GMT)
NNTP-Posting-Date: 4 May 2000 09:53:11 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Newsreader: Forte Free Agent 1.11/32.235
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

nimrod a. abing wrote:

>I think it's because the compiler seems to confuse
>between `char **string_array' and 
>`char *string_array[]'. The former is a pointer to 
>pointer to char types. The latter is an array of char
>pointers. If the compiler compiles this without issuing
>some sort of warning, then one would assume the code is
>correct when in fact they refer to two distinct types.
>
>I'll try to generate .asm output from gcc and compare
>their code. I'll send them to you as well.

I don't see the point in this, since it does the right thing in both
cases.  (Where "right" means "what it should do", not "what you
wanted it to do".)

>I'm as confused as the compiler. There should be a
>cmdline option that will detect this and warn the 
>programmer.

How do you expect the compiler to detect this?  The array is defined
in one file and used in a different one, so the compiler has to rely
on you giving it the correct information in the extern declaration.
There's no way it can tell that you've given it the wrong information.

In fact, you can avoid such problems by putting the declaration in
a common header file, which would allow the compiler to detect the
mismatch.

S.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019