delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/15/07:01:19

Date: Wed, 15 Oct 1997 13:00:03 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Erik Max Francis <max AT alcyone DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: [Q] array declaration
In-Reply-To: <3442DDB8.6CC7673E@alcyone.com>
Message-ID: <Pine.SUN.3.91.971015125944.17868D-100000@is>
MIME-Version: 1.0

On Mon, 13 Oct 1997, Erik Max Francis wrote:

> > This solves the problem with the size, but it still requires you to
> > put the type of the variable in two different places.  What if one day
> > you decide to make `myarray' int or long or an array of structs?
> 
> But how is this model any different than for functions?

It isn't different.  But in my experience, functions interface change
less (in C programs) than data definitions.

> > You put this into a header, then in one, and only one, source file
> > say "#define DEFINE_VARS".  This is ugly, but it works.
> 
> Agh.  This is like patching a tiny little hole by blowing up the dam.

This might seem like a tiny hole with the toy examples that were
posted here.  But if your data is a complex struct, having both a
declaration and the initialization in the same place helps
maintainability, since then a single header file gives a full
description of the data type.

- Raw text -


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