delorie.com/archives/browse.cgi | search |
From: | "A. Sinan Unur" <asu1 AT cornell DOT edu> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: posible bug in GCC syntax checker? |
Date: | 11 Oct 2001 22:09:37 GMT |
Organization: | Cornell University |
Lines: | 56 |
Sender: | asu1 AT cornell DOT invalid (on slip-32-102-40-91.ny.us.prserv.net) |
Message-ID: | <Xns9137B8BB094D0ASINANUNUR@132.236.56.8> |
References: | <9q4nm9$lc9$1 AT plutonium DOT btinternet DOT com> |
NNTP-Posting-Host: | slip-32-102-40-91.ny.us.prserv.net |
X-Trace: | news01.cit.cornell.edu 1002838177 21785 32.102.40.91 (11 Oct 2001 22:09:37 GMT) |
X-Complaints-To: | usenet AT news01 DOT cit DOT cornell DOT edu |
NNTP-Posting-Date: | 11 Oct 2001 22:09:37 GMT |
User-Agent: | Xnews/4.06.22 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
"Tim Nicholson" <T DOT J DOT Nicholson AT btinternet DOT com> wrote in news:9q4nm9$lc9$1 AT plutonium DOT btinternet DOT com: > Warning: Passing arg 1 of draw_item from incompatible pointer type > > ------------- source code --------- > //Local function prototype > void draw_item(const int point_array[ ][2]); > > //function main > int main(void) > { > int item[5][2]; > > {some code to initialise item}; > draw_item(item); > > return; > } > > //function draw_item > void draw_item(const int point_array[ ][2]) > { > {some code to draw a point_array}; > } > > ----------- end of code -------- > > This seemed very strange so I tried changing the prototype to see if I > could understand what was happening. Eventually, I discovered that I no > longer got the warning when I defined the prototype as: > > void draw_item(int (* const point_array) [2]); > > Now, correct me if I am wrong, but is this not the same thing in > practical terms? > > I do not understand why the compiler complains about the first > definition. Is it a GCC bug? I am using DJGPP GCC-2.95.2 : GNU C > compiler binaries with no compiler flags. It probably isn't a bug with GCC although I am no expert in rules regarding the decay of multi-dimensional arrays to pointers. Your code compiles without warnings if const is removed. Note that the code also compiles without warnings if compiled as C++. The answer to your question is tied to these facts but I do not know what the answer is. You may want to check with the folks on comp.lang.c.moderated. sinan. -- -------------------------------- A. Sinan Unur http://www.unur.com/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |