How to declare extern typedef struct?

  • Thread starter Dirk Bruere at NeoPax
  • Start date
R

Richard Tobin

Dirk Bruere at NeoPax said:
I've got a bit of code in one .c file:

typedef struct
{
SAMPLE_TYPE a0, a1, a2, a3, a4;
SAMPLE_TYPE x1, x2, y1, y2;
} biquad;

That just declares a type, not an object.
How do I declare it as an extern in another .c file that uses the
definition?

If you meant to declare a type, put it in a .h file included in both
..c files. If you meant to declare an object, declare the struct in a
..h file and either declare the object (with "extern") there too or in
the other .c file.

-- Richard
 
D

Dirk Bruere at NeoPax

Richard said:
That just declares a type, not an object.


If you meant to declare a type, put it in a .h file included in both
.c files. If you meant to declare an object, declare the struct in a
.h file and either declare the object (with "extern") there too or in
the other .c file.

-- Richard

Yes - it's so obvious once I know!
Thanks.
Another Sat night, another modafinil and on with the work... and
Wolfenstein online...

--
Dirk

http://www.transcendence.me.uk/ - Transcendence UK
http://www.theconsensus.org/ - A UK political party
http://www.onetribe.me.uk/wordpress/?cat=5 - Our podcasts on weird stuff
 
C

CBFalconer

Dirk said:
I've got a bit of code in one .c file:

_______ file biquad.h ________
typedef struct
{
SAMPLE_TYPE a0, a1, a2, a3, a4;
SAMPLE_TYPE x1, x2, y1, y2;
} biquad;
_______ EOF file biquad.h _______
How do I declare it as an extern in another .c file that uses
the definition?

Now put #include "biquad.h" in each .c file that needs it. You
will also need to define SAMPLE_TYPE.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

globals (again?) 14
Official Java Classes 10
Can an Applet beep? 4
ListModel name 10
Accessing static field 21
Free keyboard applet 5
Sorting a JList 4
Substring 53

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top