Click here to Skip to main content
15,913,570 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to get virtual memory usage Pin
ThatsAlok14-Dec-05 22:48
ThatsAlok14-Dec-05 22:48 
GeneralRe: How to get virtual memory usage Pin
sachin.kumar14-Dec-05 23:17
sachin.kumar14-Dec-05 23:17 
QuestionDirect x using c++ Pin
marihan14-Dec-05 22:33
marihan14-Dec-05 22:33 
QuestionMDI child area with and without 3D border Pin
icklePhil14-Dec-05 22:23
icklePhil14-Dec-05 22:23 
AnswerRe: MDI child area with and without 3D border Pin
icklePhil22-Dec-05 4:00
icklePhil22-Dec-05 4:00 
QuestionHow to get the browsername? Pin
Shailesh Ha14-Dec-05 22:17
Shailesh Ha14-Dec-05 22:17 
AnswerRe: How to get the browsername? Pin
David Crow15-Dec-05 2:31
David Crow15-Dec-05 2:31 
QuestionStupit Syntax Error Pin
Ametal14-Dec-05 22:06
Ametal14-Dec-05 22:06 
Hi,
I'm working on a MIPS disassembler/assembler. When I compile my code I got stupid error. I can't figure out what is wrong. Please Help.

Definitions.h
<br />
#pragma once<br />
#include <stdio.h><br />
#ifndef __DEFINITIONS_H__<br />
#define __DEFINITIONS_H__<br />
<br />
#ifdef __MSVC__<br />
	typedef unsigned __int64 dword;<br />
	typedef unsigned __int32 word;<br />
	typedef unsigned __int16 hword;<br />
	typedef unsigned __int8	 byte;<br />
#else<br />
	typedef unsigned int	word;<br />
	typedef unsigned short	hword;<br />
	typedef unsigned char	byte;<br />
#endif<br />
<br />
#ifndef NULL<br />
	#define NULL 0<br />
#endif<br />
<br />
#ifndef true<br />
	#define true 1<br />
#endif<br />
<br />
#ifndef false<br />
	#define false 0<br />
#endif<br />
<br />
typedef struct<br />
{<br />
	unsigned offset		:16;<br />
	unsigned ft			:5;<br />
	unsigned base		:5;<br />
	unsigned opcode		:6;<br />
} Inst_FPU_IType;<br />
<br />
typedef struct<br />
{<br />
	unsigned function	:6;<br />
	unsigned fd			:5;<br />
	unsigned fs			:5;<br />
	unsigned ft			:5;<br />
	unsigned fmt			:5;<br />
	unsigned opcode		:6;<br />
} Inst_FPU_RType;<br />
<br />
typedef struct <br />
{<br />
	unsigned opcode		:6;<br />
	unsigned sub			:5;<br />
	unsigned rt			:5;<br />
	unsigned fs			:5;<br />
	unsigned imm		:11;<br />
} Inst_FPU_JType;<br />
<br />
typedef struct <br />
{<br />
	unsigned function	:6;<br />
	unsigned sa			:5;<br />
	unsigned rd			:5;<br />
	unsigned rt			:5;<br />
	unsigned rs			:5;<br />
	unsigned opcode		:6;<br />
} Inst_CPU_RType;<br />
<br />
typedef struct <br />
{<br />
<br />
	unsigned immediate	:16;<br />
	unsigned rt			:5;<br />
	unsigned rs			:6;<br />
	unsigned opcode		:6;<br />
} Inst_CPU_IType;<br />
<br />
typedef struct <br />
{<br />
	unsigned inst_index	:26;<br />
	unsigned opcode		:6;<br />
} Inst_CPU_JType;<br />
<br />
typedef union<br />
{<br />
	Inst_CPU_RType	RType;<br />
	Inst_CPU_IType	IType;<br />
	Inst_CPU_JType	JType;<br />
	word			Special;<br />
} OPCODE;<br />
#define WORD2OPCODE(x) *(OPCODE*)&(x)<br />
<br />
#define INSTR_TYPE_DATA_WORD 0<br />
#define INSTR_TYPE_CPU_ITYPE 1<br />
#define INSTR_TYPE_CPU_JTYPE 2<br />
#define INSTR_TYPE_CPU_RTYPE 3<br />
<br />
#pragma warning(disable : 4996)<br />
<br />
<br />
typedef struct<br />
{<br />
	char Name[5];<br />
	byte No;<br />
} Register;<br />
<br />
const Register RegTable[] =<br />
		{<br />
			{"zero",	0},<br />
                        ...<br />
			{"ra",		31},<br />
		};<br />
#define REGISTER_COUNT 31<br />
<br />
typedef struct<br />
{<br />
	char	Name[10];<br />
	word	OpcodeMask;<br />
	word	FieldMask;<br />
	char	Syntax[15];<br />
} Instruction;<br />
<br />
const Instruction InstTable[] = <br />
		{<br />
			{"addi",	0x20000000, 0xFC000000, "$t, $s, i"},<br />
                        ....<br />
			{"xor",		0x00000026,	0xFC00003F, "$d, $s, $t"},<br />
		};<br />
#define INSTRUCTION_COUNT 49<br />
<br />
<br />
#endif<br />



Disassembler.hpp
<br />
#ifndef __DISASSEMBLER_HPP__<br />
#define __DISASSEMBLER_HPP__<br />
#include "definitions.h"<br />
#pragma warning( disable : 4290 )<br />
<br />
#define DISASSEMBLER_ERROR_WARNING		0<br />
#define DISASSEMBLER_ERROR_ERROR		1<br />
#define DISASSEMBLER_ERROR_INTERNAL		2<br />
<br />
typedef struct<br />
{<br />
	word Type;<br />
	char Text[250];<br />
} DisassemblerErrorDesc;<br />
<br />
const DisassemblerErrorDesc DisassemblerErrors[] =<br />
{<br />
	{DISASSEMBLER_ERROR_INTERNAL,	"No such a register"},<br />
	{DISASSEMBLER_ERROR_INTERNAL,	"Instruction table parameter syntax error"},<br />
	{DISASSEMBLER_ERROR_ERROR,		"There is no such a instruction"},<br />
};<br />
#define ASSEMBLER_ERROR_COUNT		6<br />
#define BUFFER_CHUNK_SIZE sizeof(char) * 200<br />
<br />
/* Line 24 */ class CDisassembler<br />
{<br />
private :<br />
	friend int main(char** argv, int argc);<br />
	void (*SendOutput)(char* Text);<br />
	void (*SendError)(char* Text, word Pos, word Item);<br />
<br />
	bool RaiseError(word err, word pos, word opcode);<br />
	inline void Hex(word number, char *buffer);<br />
	inline char* DecodeRegister(byte id) throw (int);<br />
	void DecodeParam(Instruction inst, OPCODE opcode, char *buffer) throw(int);<br />
	inline void ManageMemory(char *&buffer, word size, word bufferpos, word &buffersize) throw(int);<br />
	void DecodeOpcode(word opcode, char* buffer) throw(int);<br />
public:<br />
	char* Disassemble(word* binary, word size);<br />
	CDisassembler();<br />
	CDisassembler(void (*Output)(char*), void (*Error)(char*, word, word));<br />
	~CDisassembler();<br />
/*Line 42*/};<br />
<br />
#endif<br />


Here is my error output:
------ Build started: Project: Disassembler, Configuration: Debug Win32 ------
Compiling...
main.c
c:\projects\disassembler\disassembler.hpp(24) : error C2061: syntax error : identifier 'CDisassembler'
c:\projects\disassembler\disassembler.hpp(24) : error C2059: syntax error : ';'
c:\projects\disassembler\disassembler.hpp(25) : error C2449: found '{' at file scope (missing function header?)
c:\projects\disassembler\disassembler.hpp(42) : error C2059: syntax error : '}'
Build log was saved at "file://c:\Projects\Disassembler\Debug\BuildLog.htm"
Disassembler - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

As you can see I'm having error at
class CDisassembly
{
code. What is wrong with this very basic statement. I have scanned the above lines for a syntax error but found nothing. Have any idea ?
Thanks a lot.

-- modified at 4:35 Thursday 15th December, 2005
AnswerRe: Stupit Syntax Error Pin
toxcct14-Dec-05 22:17
toxcct14-Dec-05 22:17 
GeneralRe: Stupit Syntax Error Pin
Ametal14-Dec-05 22:25
Ametal14-Dec-05 22:25 
AnswerRe: Stupit Syntax Error Pin
8ki14-Dec-05 22:29
8ki14-Dec-05 22:29 
GeneralRe: Stupit Syntax Error Pin
Ametal14-Dec-05 22:35
Ametal14-Dec-05 22:35 
GeneralRe: Stupit Syntax Error Pin
toxcct14-Dec-05 23:03
toxcct14-Dec-05 23:03 
AnswerRe: Stupit Syntax Error Pin
kakan14-Dec-05 22:37
professionalkakan14-Dec-05 22:37 
GeneralRe: Stupit Syntax Error Pin
Ametal14-Dec-05 22:39
Ametal14-Dec-05 22:39 
GeneralRe: Stupit Syntax Error Pin
kakan14-Dec-05 22:44
professionalkakan14-Dec-05 22:44 
GeneralRe: Stupit Syntax Error Pin
Ametal14-Dec-05 22:45
Ametal14-Dec-05 22:45 
GeneralRe: Stupit Syntax Error Pin
kakan14-Dec-05 22:47
professionalkakan14-Dec-05 22:47 
AnswerRe: Stupit Syntax Error Pin
khan++14-Dec-05 23:11
khan++14-Dec-05 23:11 
GeneralRe: Stupit Syntax Error Pin
Ametal14-Dec-05 23:14
Ametal14-Dec-05 23:14 
QuestionRe: Stupit Syntax Error Pin
David Crow15-Dec-05 2:33
David Crow15-Dec-05 2:33 
QuestionHow to change the name of my application Pin
mikobi14-Dec-05 21:47
mikobi14-Dec-05 21:47 
AnswerRe: How to change the name of my application Pin
toxcct14-Dec-05 22:18
toxcct14-Dec-05 22:18 
GeneralRe: How to change the name of my application Pin
mikobi14-Dec-05 23:11
mikobi14-Dec-05 23:11 
Questiontemplate class Pin
Nishad S14-Dec-05 21:45
Nishad S14-Dec-05 21:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.