Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forward Declarations 1

Status
Not open for further replies.

chipperMDW

Programmer
Mar 24, 2002
1,268
US
Is the following guaranteed to be doable in just plain, pre-C99 ANSI C? (Without C++, and without compiler-specific tricks).


Code:
/* hidden.h */

#ifndef GLAH_H
#define GLAH_H

struct hidden;

typedef struct hidden hidden_t;

void foo_hidden( hidden_t*, int );

#endif



/* hidden.c */

typedef struct hidden
{
    int x;
} hidden_t;

void foo_hidden( hidden_t* h, int y )
{
    h->x = y;
}
 
Just to make clear the hypothetical usage of this example, assume this library also provides a means of obtaining and freeing a dynamically allocated
Code:
hidden_t
.
 
Yes - I've got some compilers dating back to 1988 and it works on them. It is used a lot in X-Windows.

I think the hippy term for it is PIMP or PIMPL.
 
Heh heh. Yup, pimpl it is. I know the technique and use variants of it in C++, but I wanted to make sure it worked everywhere (or some suitably large subset thereof) since I'm doing something that needs to be usable in "lowest common denominator" environments.

Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top