I'm writing a program that must normalize audio *.wav
file.
There is a task "to display header's data": ChunkId
, ChunkSize
and so on.
I want to make a function named display_hdr
(In order to have less code in the main.c file, so it will become esier to read this code). To do this I have to pass this function header's variable (variable of type header) as argument, but it writes
functions.h|1|error: unknown type name 'header'|
main.c:
typedef struct FMT
{
char SubChunk1ID[4];
int SubChunk1Size;
short int AudioFormat;
short int NumChannels;
int SampleRate;
int ByteRate;
short int BlockAlign;
short int BitsPerSample;
} fmt;
typedef struct DATA
{
char Subchunk2ID[4];
int Subchunk2Size;
int Data[];
} data;
typedef struct HEADER
{
char ChunkID[4];
int ChunkSize;
char Format[4];
fmt S1;
data S2;
} header;
Header's variable was declared in this way:
header hdr;
And now, when I try to pass hdr
to my function it prints an error
:
functions.h|1|error: unknown type name 'header'|
functions.h
void display_hdr( header hdr )
{
printf("\n*********************************\n");
printf("WAVE file's metadata:\n\n");
printf("%4.4s\n", hdr.ChunkID );
printf("%d\n", hdr.ChunkSize );
printf("%4.4s\n", hdr.Format );
printf("%4.4s\n", hdr.S1.SubChunk1ID );
printf("%d\n", hdr.S1.SubChunk1Size );
printf("%d\n", hdr.S1.AudioFormat );
printf("%d\n", hdr.S1.NumChannels );
printf("%d\n", hdr.S1.SampleRate );
printf("%d\n", hdr.S1.ByteRate );
printf("%d\n", hdr.S1.BlockAlign );
printf("%d\n", hdr.S1.BitsPerSample );
printf("%4.4s\n", hdr.S2.Subchunk2ID );
printf("%d\n", hdr.S2.Subchunk2Size ); /// SAMPLES' SIZE
printf("\n*********************************\n");
return;
}
So, how to pass a variable of your own (non-standard) type to a function as an argument?