delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/10/31/23:14:07

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: SIGSEGV page fault DOS but not Windows
Date: 31 Oct 2000 14:17:35 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 35
Message-ID: <8tmk9v$a41$1@nets3.rz.RWTH-Aachen.DE>
References: <8tknba$509$1 AT plutonium DOT btinternet DOT com> <39fda5a2 DOT sandmann AT clio DOT rice DOT edu> <8tlt8t$p3$1 AT neptunium DOT btinternet DOT com>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 973001855 10369 137.226.32.75 (31 Oct 2000 14:17:35 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 31 Oct 2000 14:17:35 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Tim Nicholson <djgpp_mail AT gizzy DOT co DOT uk> wrote:

> char button_label_array[500][4][11] = { ".....

> In other words there are 500 labels in four languages each up to 10 chars
> long.
> label, in my program is defined as a char pointer and set like so..
> label = &button_label_array[x];  (where x always = 0 to 99).

That's incorrect code, then. &button_label_array[x] is an expression of type

	address of (element of (char array [500][4][11])
	= address of ( char array [4][11])
	= pointer to (char array [11])

This is not compatible to a pointer to a char, so assigning this to a
'label' declared as char pointer is an error.

gcc at full warning level (-O2 -Wall -W) should have complained about
this.

> I pass (*label)[setup->language] to the function. 

Here, '*label' is of type 'char', and accessing element number
(setup->language) of it is not going to do what you thought it does.

You have to define 'label' as pointer to a char[11] array:

	char (*label)[11];



-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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