|
To get the default browser associated with .htm or .html extensions, use FindExecutable() or AssocQueryString() .
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
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 />
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 />
};<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
|
|
|
|
|
i don't know what's wrong, but the error is in disassembler.hpp, around line 24, so i don't understand why you gave the whole code of definition.h
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
Thanks for your reply.
I have included definitions.h in disassembler.hpp so that source of this error can be in definitions.h. In my past experiences precompiler directives can be source of errors like this. Especially included files. Some times I had extra ';' token at the end of a header file and I got errors similar to this error in file that included the header file.
I thought that maybe I have error in definitions.h.
I gonna be crazy. What the heck is this error ?!? It's so simple statement.
-- modified at 4:25 Thursday 15th December, 2005
|
|
|
|
|
What is that #include doing in begining of definitions.h?I dont know much about programing but i think you should include something, like file?Could that be problem?
|
|
|
|
|
Sorry I think there is a copy/paste problem. that line should be #include <stdio.h> I'm gone fix the post.
Thans a lot for your reply...
|
|
|
|
|
|
You could run the code through the preprocessor (only) and examine the output.
That's one way...
|
|
|
|
|
How can I do it ?
Thanks for your reply.
|
|
|
|
|
|
thans a lot. I'll try it.
|
|
|
|
|
Good luck.
The output from the preprocessor isn't very good looking, but it's what the compiler gets.
Kakan
|
|
|
|
|
I think you are getting these error messages because you are including a C++ header file and a class in a .C file. The file which is including the .HPP file must be a .CPP file.
this is this.
|
|
|
|
|
It worked !
I have included this file in main.c.
Now I renamed it to main.cpp and compiled the solution. It works.
Thanks a lot for your help.
|
|
|
|
|
Ametal wrote: Compiling...
main.c
Should this be main.cpp instead?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I want to change the name of my application to appear at the top of my screen.
I am using a menu which call many Views, one at time.
When i open the program, the New name appear and when a shift to another view, the new name disapear.
Where can I fix it so that it cann't change
I learn my self
|
|
|
|
|
|
Your Are right,
I try it, it's work well
Thanks for all
Best new year for you and your familly
|
|
|
|
|
Hi,
I create template class, declared in .h file and implemented in .cpp file. But it do not compile the functions in the .cpp file.
But when I put them in the .h file, it's OK.
The .cpp file is in the source files list.
I use VC 6.
Thank you.
- NS -
|
|
|
|
|
Is it possible to send the errors or the files ?
I think that you got linker error when you had tried to compile.
|
|
|
|
|
Yes. Linker error for only those functions used.
- NS -
|
|
|
|
|
Link error:
TemplateClass.obj : error LNK2001: unresolved external symbol "protected: struct DataList<int>::NODE_t * __thiscall DataList<int>::DetachNode(unsigned int)" (?DetachNode@?$DataList@H@@IAEPAUNODE_t@1@I@Z)
Debug/TemplateClass.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
But this function is in the .cpp file.
It is...
template < typename T >
DataList < T > ::NODE_t* DataList < T > ::DetachNode( UINT uIndex_i )
{
// some codes
}
If I put this function in .h file, it works fine.
<B>- NS -</B>
|
|
|
|
|
Delete all your debug or release directory.
Make sure you have exacly the the same function definition in cpp and h file.
And don't include cpp file in header file
Recompile file.
|
|
|
|
|
I did it. But no change.
- NS -
|
|
|
|