GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 12-Jun-2004, 13:18
pablowablo pablowablo is offline
New Member
 
Join Date: Apr 2004
Posts: 24
pablowablo is on a distinguished road

Hmm what seems to be the problem here? error C2061: syntax error


I have 3 files. A header file, and 2 .c files. When I include the header file in the first .c file it works fine... but when I compile the second .c file that includes the same header file I get the following error

Quote:
Compiling...
Mp3_Main_Decoder.c
f:\c++ mp3 decoder\bitstream.h(19) : error C2061: syntax error : identifier 'myFile'
f:\c++ mp3 decoder\bitstream.h(19) : error C2059: syntax error : ';'
Error executing cl.exe.

Mp3_Main_Decoder.obj - 2 error(s), 0 warning(s)


Here are the files:


the header file:

CPP / C++ / C Code:
/***************************************************************************
  Filename: Bitstream.h                                          
  Author: Pablo                                                          
  Description: This file contains the stream of data.. dito ung buffers.  
				prolly independent of platform so babaguhin pa to
/**************************************************************************/

#include "Mp3_Declarations.h"
#include <iostream.h>
#include <fstream.h>
#include <sys/stat.h>




struct stat results;
long size, count;
ifstream myFile;

STATUS openFile(STRING filename)
{
	/*if (stat(filename, &results) == 0)
		size = results.st_size;


	myFile.open(filename, ios::in | ios::binary);
	
	if(!myFile)
		return ERROR;

	return OK;*/
}

/***************************************************************************
	Name: GetByte()
	Author: Pablo
	Description: Returns the current byte from the bitstream
	Parameters: None
	Return: an unsigned int that contains the byte in the significant bits
****************************************************************************/

UINT32 GetByte()
{

/*	UCHAR8 * temp = 0;
	temp = new UCHAR8;
	
	
	myFile.read(temp, 1);

	cout << *temp << " eto \n";
	
	count++;
	return((UINT32)*temp);

*/
}

void movePointer()
{

	//myFile.seekp(size - 1);
}

void closeFile()
{
//	myFile.close();
}


this is the c file that compiles properly

CPP / C++ / C Code:


#include "Bitstream.h"
#include "Mp3_Declarations.h"
#include <iostream.h>
#include<fstream.h>
#include <sys/stat.h>

void main()
{

	
	

	
 if(openFile("testing.mp3") == OK)

	Mp3_Read_Header();



 closeFile();
 }	
 
 
 
 

the c file with errors

CPP / C++ / C Code:
/***************************************************************************
  Filename: Mp3_Main_Decoder.c                                          
  Author: Pablo                                                          
  Description: This file contains the main functions of the Mp3 Decoder
/**************************************************************************/

#include "Mp3_Declarations.h"
#include "Bitstream.h"

//bitrate table for MPEG audio layers
UINT32 g_mpeg_bitrates[3][15] = {
	{//Layer 1
		0, 32000, 64000, 96000, 128000, 160000, 192000, 224000,
		256000, 288000, 320000, 352000, 384000, 416000, 448000
	},

	{//Layer 2
		0, 32000, 48000, 56000, 64000, 80000, 96000, 112000,
		128000, 160000, 192000, 224000, 256000, 320000, 384000
	},

	{//Layer 3
		0, 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000,
		128000, 160000, 192000, 224000, 256000, 320000
	}
};

//Sampling frequencies in hertz
UINT32 g_sampling_frequency[3] = 
{
	44100 * Hz,
	48000 * Hz,
	32000 * Hz
};

mp3_header g_frame_header;


/***************************************************************************
	Name: Mp3_Read_Header()
	Author: Pablo
	Description:
	Parameters: None
	Return:
****************************************************************************/

STATUS Mp3_Read_Frame()
{

	return(OK);
}



/***************************************************************************
	Name: Mp3_Read_Header()
	Author: Pablo
	Description:
	Parameters: None
	Return: OK or ERROR
****************************************************************************/

STATUS Mp3_Read_Header()
{
	UINT32 byte1, byte2, byte3, byte4, header;
	
	openFile("testing.mp3");
	byte1 = GetByte();
	byte2 = GetByte();
	byte3 = GetByte();
	byte4 = GetByte();

	return(OK);
}



P.S. how do I do the syntax higlighting thing here? hmm C++ code?
Last edited by dsmith : 14-Jun-2004 at 07:34. Reason: Use [c] & [/c] for syntax highlighting
  #2  
Old 12-Jun-2004, 13:39
aaroncohn's Avatar
aaroncohn aaroncohn is offline
Regular Member
 
Join Date: Feb 2004
Location: Bay Area, CA.
Posts: 564
aaroncohn is a jewel in the roughaaroncohn is a jewel in the roughaaroncohn is a jewel in the rough
Use the [C] & [/C] tags to hi-light your code. I can't really tell what the error is, but I have a question. Why is all of your code commented out in bistream.h?
__________________
-Aaron
  #3  
Old 12-Jun-2004, 14:31
machinated machinated is offline
Regular Member
 
Join Date: Mar 2004
Location: victoria, canada
Posts: 324
machinated has a spectacular aura aboutmachinated has a spectacular aura about
open your bistream.h and mp3declarations.h files and put in the following statements like so:
CPP / C++ / C Code:
//bitstream.h


//beginning of file
#ifndef __bitstream_h__   
#define__bitstream_h__ 


....
//file content
....

#endif
//end of file
do the same with mp3_declarations.h file and then see if you have any problems.
__________________
spasms!!!
  #4  
Old 12-Jun-2004, 19:27
pablowablo pablowablo is offline
New Member
 
Join Date: Apr 2004
Posts: 24
pablowablo is on a distinguished road
Quote:
open your bistream.h and mp3declarations.h files and put in the following statements like so:

C / C++ Code:
//bitstream.h


//beginning of file
#ifndef __bitstream_h__
#define__bitstream_h__


....
//file content
....

#endif
//end of file
do the same with mp3_declarations.h file and then see if you have any problems.

thanks, but I already tried that before and it didn't work

I still can't get it to work

Quote:
Why is all of your code commented out in bistream.h?


Thanks! Wish I could edit my post here.... Anyway, the functions are commented out because it causes more errors. Hmmm I'm wondering why the line
CPP / C++ / C Code:
 fstream myFile; 
is the only one causing the errors, while the other declarations seem to be fine. I always get the same error whereever I put that particular line.
  #5  
Old 12-Jun-2004, 21:47
machinated machinated is offline
Regular Member
 
Join Date: Mar 2004
Location: victoria, canada
Posts: 324
machinated has a spectacular aura aboutmachinated has a spectacular aura about
try getting rid of .h and instead use std:
CPP / C++ / C Code:
#include<fstream>
#include<iostream>
using namespace std;
__________________
spasms!!!
  #6  
Old 12-Jun-2004, 22:11
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,243
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Your header file defines executable functions. It should be a CPP file.

You should not define variables and functions in headers -- only declarations.
__________________

Age is unimportant -- except in cheese
 
 

Recent GIDBlogMeeting the local Iraqis by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Operator Overloading: << aaroncohn C++ Forum 36 07-Dec-2004 19:22
OpenGL always reports error mvt OpenGL Programming 2 04-Jun-2004 06:42
Visual C++ 6 Compiler error vip3r C++ Forum 2 13-Apr-2004 14:34
Another "parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING" problem Go3Team MySQL / PHP Forum 3 28-Feb-2004 17:35
[script] E-mail webmaster error page BobbyDouglas PHP Code Library 0 19-Aug-2003 20:10

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 14:23.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.