public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Peter Haase <p.haase@tu-harburg.de>
To: gsl-discuss@sources.redhat.com
Subject: Forward declaration is not possible
Date: Thu, 12 Dec 2002 06:08:00 -0000	[thread overview]
Message-ID: <200212121428.04612.p.haase@tu-harburg.de> (raw)

Hi,
using GSL to implement some random generators, I would like to make a forward 
declaration for 'gsl_rng' and 'gsl_rng_type' (Otherwise, I have to include 
the GSL header files in my header file and clients using my random generators 
must have these GSL header files available ). Unfortunatley a forward 
declaration is not possible since both 'gsl_rng' and 'gsl_rng_type' are not 
names of a struct but are defined by typedef as new types:

(In gsl_rng.h:)

typedef struct 
{
   char* name;
   ....
} gsl_rng;



The reason for this is obvious to avoid the keyword struct when using the name 
gsl_rng in c-code.

My suggestion is to use 'gsl_rng' as a name of the struct and as typename for 
that struct:

(Suggested new code in gsl_rng.h)

typedef struct gsl_rng      // ( ansi c ? if not use 'tag_gsl_rng' instead)
{
   char* name;
   ....
} gsl_rng; 

With that code it is possible to use the gsl as used before and it is possible 
to use a forward declaration and hence to avoid unneccessary #includes of the 
GSL header files. I'm not pretty shure if it's strict ANSI C code when using 
the same token 'gsl_rng' for both the name and the typename (my GCC 3.2 
Compiler does not complain about that). If that is not allowed in ANSI C, the 
token 'tag_gls_rng' could be used for the name of struct (see comment above).
Even that is much more convenient than dealing without a forward declaration.

Peter 

  

             reply	other threads:[~2002-12-12 13:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-12  6:08 Peter Haase [this message]
2002-12-13  8:42 ` Brian Gough
2002-12-17  9:08   ` Peter Haase
2002-12-17 15:22     ` Atakan Gurkan
2002-12-19 11:40     ` Brian Gough
2002-12-21 11:47       ` Peter Haase
2002-12-23  7:14         ` Brian Gough

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200212121428.04612.p.haase@tu-harburg.de \
    --to=p.haase@tu-harburg.de \
    --cc=gsl-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).