public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
* Forward declaration is not possible
@ 2002-12-12  6:08 Peter Haase
  2002-12-13  8:42 ` Brian Gough
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Haase @ 2002-12-12  6:08 UTC (permalink / raw)
  To: gsl-discuss

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 

  

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-12-23 15:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-12  6:08 Forward declaration is not possible Peter Haase
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

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