Visual C (2008) is acting as if I never included a header file (wave.h) that I am using, but the #include statement is definitely there. Here's my main (BPM analyze.c):

#include "stdafx.h"

#include "common.h"
#include "sound.h"
#include "wave.h"

int main(int argc, char* argv[])
{
	SAMPLE samples[2];
	unsigned int i, j;
	WAV_FILE file;
	FRAME *frames;

	getWaveFile(&file, "Lobby.wav");
	extractFrames(frames, &file, 0, 1);

	//printf("32 bit: ");
	for(i = 0; i <= 1; i++)
	{
		for(j = 0; j < file->info->numChannels; j++)
		{
			printf("%d ", frames[i][j]);
		}
	}

	getchar();
	return 0;
}

Common.h (probably not the issue):

#ifndef COMMON_H
#define COMMON_H

#define MAX(a, b) ((a > b) ? a : b)

typedef enum{false, true} bool;

#endif

Sound.h:

#ifndef SOUND_H
#define SOUND_H

typedef unsigned int SAMPLE_32BIT;
typedef unsigned int SAMPLE_24BIT;
typedef unsigned short SAMPLE_16BIT;
typedef unsigned char SAMPLE_8BIT;
typedef union
{
	SAMPLE_32BIT _32bit;
	SAMPLE_24BIT _24bit;
	SAMPLE_16BIT _16bit;
	SAMPLE_8BIT _8bit;
} SAMPLE;
typedef SAMPLE **FRAME;

#endif

Wave.h:

#ifndef WAVE_H
#define WAVE_H

typedef struct
{
	unsigned short formatTag;
	unsigned short numChannels;
	unsigned int samplesPerSec;
	unsigned int bytesPerSec;
	unsigned short blockAlign;
} WAVE_INFO;
typedef struct
{
	WAVE_INFO *info;
	SAMPLE *data;
} WAVE_FILE;

bool getWaveData(WAVE_FILE *file, char *filename)
{
	// function body, not important
}

void extractWaveFrames(FRAME *frames, WAVE_FILE *file, unsigned int startFrame, unsigned int endFrame)
{
	// function body, not important
}

#endif

And here's Visual C's complaints:

bpm analyze.c(11) : error C2065: 'WAV_FILE' : undeclared identifier
bpm analyze.c(11) : error C2146: syntax error : missing ';' before identifier 'file'
bpm analyze.c(11) : error C2065: 'file' : undeclared identifier
bpm analyze.c(12) : error C2275: 'FRAME' : illegal use of this type as an expression
        sound.h(15) : see declaration of 'FRAME'
bpm analyze.c(12) : error C2065: 'frames' : undeclared identifier
bpm analyze.c(14) : warning C4013: 'getWaveFile' undefined; assuming extern returning int
bpm analyze.c(14) : error C2065: 'file' : undeclared identifier
bpm analyze.c(15) : warning C4013: 'extractFrames' undefined; assuming extern returning int
bpm analyze.c(15) : error C2065: 'frames' : undeclared identifier
bpm analyze.c(15) : error C2065: 'file' : undeclared identifier
bpm analyze.c(20) : error C2065: 'file' : undeclared identifier
bpm analyze.c(20) : error C2223: left of '->info' must point to struct/union
bpm analyze.c(22) : error C2065: 'frames' : undeclared identifier
bpm analyze.c(22) : error C2109: subscript requires array or pointer type

I get those same errors if I don't include wave.h at all. Any clue what is going on?

The structure in wave.h is typedef'd as 'WAVE_FILE' and in your analyze.c you are using

WAV_FILE file;

Don't you think its a typing mistake and should be WAVE_FILE file???

Wow, I was just refencing things by all the wrong names. I knew it was something stupid like that! Thanks for the catch, me_ansh.

I think the thread is closed....should be marked as solved...

Wave.h:

#ifndef WAVE_H
#define WAVE_H

typedef struct
{
	unsigned short formatTag;
	unsigned short numChannels;
	unsigned int samplesPerSec;
	unsigned int bytesPerSec;
	unsigned short blockAlign;
} WAVE_INFO;
typedef struct
{
	WAVE_INFO *info;
	SAMPLE *data;
} WAVE_FILE;

bool getWaveData(WAVE_FILE *file, char *filename)
{
	// function body, not important
}

void extractWaveFrames(FRAME *frames, WAVE_FILE *file, unsigned int startFrame, unsigned int endFrame)
{
	// function body, not important
}

#endif

Prepocessor directives (including #include, macros); structures, enum and typedef; global (and extern) variable declarations; function prototypes; comments; are alright to write onto a header file, but it should not include source code that will cause machine code to be generated.

They should be put in .c files? I never learned great project design.

>They should be put in .c files?
Correct.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.