delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/20/09:31:04

From: Hans-Bernhard Broeker <broeker AT acp3bf DOT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Problem with include files...
Date: 20 Jan 2000 13:19:11 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 26
Message-ID: <86720f$ctp$1@nets3.rz.RWTH-Aachen.DE>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1000120092832 DOT 21977U-100000 AT is>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 948374351 13241 137.226.32.75 (20 Jan 2000 13:19:11 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 20 Jan 2000 13:19:11 GMT
User-Agent: tin/1.4-19991113 ("No Labels") (UNIX) (Linux/2.0.0 (i586))
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:
> On Wed, 19 Jan 2000, David Cleaver wrote:

>> unsigned char table011[][] = {{ 0, 0},

> This is not valid C: you can't leave both dimensions unspecified.
> Only the last dimension can be left unspecified.

Close, but it's exactly the other way round: it's the *first*
array dimension that can be left open, i.e.:

   unsigned char table011[][2] = {{ 0, 0},

is the right way.

And, as a related issue, no initialized variable definition like this
should usually be put into a header file. You'ld get "multiple
definition" errors from the linker, if this header file is linked into
more than one .c file.  Instead, have 'extern unsigned char
table[][2];' in the header, and move the initialized definition into
the .c file (or a 'private header' which is not made visible to users
of this code module).

-- 
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