473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Too many types in declaration

Hi,
I'm learning C++, i wrote a small project that has these files:

Log.h
Log.cpp

Render.h
Render.cpp

Tid.h
Tid.cpp

________________________
In TID.h :

#ifndef TID_HPP_INCLUDED
#define TID_HPP_INCLUDED

typedef unsigned char byte;

......
#define EXIT_SUCCESS 0
.....
#define BGI_DRIVER "SVGA64K"
#define BGI_600_480 4
#define SCREEN_WIDTH 600
....
#define LOG_FILE_NAME "log.txt"

#include <graphics.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <mem.h>
#include <stdio.h>

#include "Log.h"
#include "MouseLib.h"
#include "Render.h"

#endif

-----------------------------------
TID.CPP

#include "TiD.h"

int main(void)
{
...........
return EXIT_SUCCESS;
}

___________________
In LOG.h i have:
#ifndef LOG_HPP_INCLUDED
#define LOG_HPP_INCLUDED

void CLog_write(const char *s);
#endif

________________________________
Log.CPP

#include "TID.h"

void CLog_write(const char* s){ ../*write file*/... }
------------------------------------------------------
Render.H
#include "tid.h"

#ifndef RENDER_ENGINE_HPP
#define RENDER_ENGINE_HPP

typedef struct tagBITMAP{
.....} BITMAP;
class CRender
{
public:
CRender();
~CRender();
void fskip(FILE * fp,int);
......
private:
......
}

---------------------------------------------------------
RENDER.CPP

#include "TID.h"

// Initialize graphic mode.
CRender::CRender()
{
/* init BGI driver */
}

void CRender::PutImage (const char * filename,int x,int y,int ops)
const
{
FILE *fp;
....
CLog_write("CRender::PutImage() : Invalid BMP file");
.....
}
....

--------------------------------------------------------

When i compile in TC++ 3.0 i have error message:
Error LOG.CPP 3: Too many types in declaration.
I think the problem maybe about "include header" but i don't know much
about may files and many header, before i wrote simple programs with
1 file (and one header).

Thank for your help.
TLE

Nov 28 '06 #1
12 9154
tienlx wrote:
Hi,
I'm learning C++, i wrote a small project that has these files:

Log.h
Log.cpp

Render.h
Render.cpp

Tid.h
Tid.cpp

________________________
In TID.h :

#ifndef TID_HPP_INCLUDED
#define TID_HPP_INCLUDED

typedef unsigned char byte;

.....
#define EXIT_SUCCESS 0
....
#define BGI_DRIVER "SVGA64K"
#define BGI_600_480 4
#define SCREEN_WIDTH 600
...
#define LOG_FILE_NAME "log.txt"

#include <graphics.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <mem.h>
#include <stdio.h>

#include "Log.h"
#include "MouseLib.h"
#include "Render.h"

#endif

-----------------------------------
TID.CPP

#include "TiD.h"

int main(void)
{
...........
return EXIT_SUCCESS;
}

___________________
In LOG.h i have:
#ifndef LOG_HPP_INCLUDED
#define LOG_HPP_INCLUDED

void CLog_write(const char *s);
#endif

________________________________
Log.CPP

#include "TID.h"

void CLog_write(const char* s){ ../*write file*/... }
------------------------------------------------------
Render.H
#include "tid.h"

#ifndef RENDER_ENGINE_HPP
#define RENDER_ENGINE_HPP

typedef struct tagBITMAP{
....} BITMAP;
class CRender
{
public:
CRender();
~CRender();
void fskip(FILE * fp,int);
.....
private:
.....
}

---------------------------------------------------------
RENDER.CPP

#include "TID.h"

// Initialize graphic mode.
CRender::CRender()
{
/* init BGI driver */
}

void CRender::PutImage (const char * filename,int x,int y,int ops)
const
{
FILE *fp;
...
CLog_write("CRender::PutImage() : Invalid BMP file");
....
}
...

--------------------------------------------------------

When i compile in TC++ 3.0 i have error message:
Error LOG.CPP 3: Too many types in declaration.
I think the problem maybe about "include header" but i don't know much
about may files and many header, before i wrote simple programs with
1 file (and one header).

Thank for your help.
Nothing sticks out. See the guidelines for posting code:

http://parashift.com/c++-faq-lite/ho...t.html#faq-5.8

Post a minimal but *complete* example that we can copy and paste
unchanged into our editors to see the error you get. (Note that we
don't have non-standard headers like graphics.h, dos.h, or conio.h.)

Cheers! --M

Nov 28 '06 #2
mlimber wrote:
tienlx wrote:
>Hi,
I'm learning C++, i wrote a small project that has these files:
[...]
>------------------------------------------------------
Render.H
#include "tid.h"

#ifndef RENDER_ENGINE_HPP
#define RENDER_ENGINE_HPP

typedef struct tagBITMAP{
....} BITMAP;
class CRender
{
public:
CRender();
~CRender();
void fskip(FILE * fp,int);
.....
private:
.....
}
^^^^
There seems to be a missing semicolon here.
>>
[...]
>
Nothing sticks out.
That's true, it doesn't really "stick out"...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 28 '06 #3

mlimber wrote in message...
>tienlx wrote:
>Hi,
I'm learning C++, i wrote a small project that has these files:
________________________
In TID.h :
#ifndef TID_HPP_INCLUDED
#define TID_HPP_INCLUDED

typedef unsigned char byte;
.....
To OP:

#ifdef EXIT_SUCCESS
#undef EXIT_SUCCESS
>#define EXIT_SUCCESS 0
#endif // #ifdef EXIT_SUCCESS
>....
...
#define LOG_FILE_NAME "log.txt"

#include <graphics.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <mem.h>
#include <stdio.h>
Maybe post to an 'C' NG? <G>
Or....

// >#include <stdlib.h>
#include <cstdlib>

// >#include <conio.h>
// >#include <dos.h>
// >#include <mem.h>
#include <memory>

// >#include <stdio.h>
#include <cstdio>
>--------------------------------------------------------
--
Bob R
POVrookie
Nov 28 '06 #4
On 28 Nov 2006 07:03:19 -0800, "tienlx" <ti*****@gmail.comwrote in
comp.lang.c++:
Hi,
I'm learning C++, i wrote a small project that has these files:
[snip]
When i compile in TC++ 3.0 i have error message:
[snip]
I think the problem maybe about "include header" but i don't know much
about may files and many header, before i wrote simple programs with
1 file (and one header).

Thank for your help.
DO NOT ATTEMPT TO LEARN C++ USING Turbo C++ 3.0!!!

This compiler is more than a dozen years old, and from long before the
C++ language standard. It is an exercise in futility.

If you want to learn C++, get an up to date compiler. There are
several free for download.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 29 '06 #5
tienlx wrote:
class CRender
{
}
Missing semicolon.

You got that rather esoteric error message because the compiler
sees:

class CRender { } int main()

and thinks you are declaring main to return a CRender and an int,
but functions are only allowed to have one return type.

Nov 29 '06 #6
Thanks. I solve that problems.

when compile i have error message:
RENDER.H 14: Declaration syntax error.

I don't know why it happens.

#include <stdio.h>

#ifndef RENDER_ENGINE_HPP
#define RENDER_ENGINE_HPP

typedef struct tagBITMAP
{
unsigned short width;
unsigned short height;
unsigned char pallete[256*3];
unsigned char * data;
}BITMAP;

class CRender
{
public:
// Initialize graphic mode.
CRender();
~CRender();
void ClearScreen();
int GetLastError();
void WaitForRetrace(void);
void SetPalette(byte *palette);
void fskip(FILE * fp,int);
void PutImage (const char * filename,int x,int y,int ops) ;
private:
int m_iGDriver;
int m_iGMode;
int m_iErrorcode;

};

#endif

Nov 29 '06 #7
tienlx wrote:
Thanks. I solve that problems.

when compile i have error message:
RENDER.H 14: Declaration syntax error.
Which one is line 14?
>
I don't know why it happens.
See FAQ 5.8.
>
#include <stdio.h>

#ifndef RENDER_ENGINE_HPP
#define RENDER_ENGINE_HPP

typedef struct tagBITMAP
{
unsigned short width;
unsigned short height;
unsigned char pallete[256*3];
unsigned char * data;
}BITMAP;

class CRender
{
public:
// Initialize graphic mode.
CRender();
~CRender();
void ClearScreen();
int GetLastError();
void WaitForRetrace(void);
void SetPalette(byte *palette);
What's a "byte"?
void fskip(FILE * fp,int);
void PutImage (const char * filename,int x,int y,int ops) ;
private:
int m_iGDriver;
int m_iGMode;
int m_iErrorcode;

};

#endif
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 29 '06 #8
tienlx wrote:
>
when compile i have error message:
RENDER.H 14: Declaration syntax error.

I don't know why it happens.
You need to say which line is line 14, and post the exact
code you are compiling. (For example, "byte" in the code
below is undefined, but that can't be line 14).
#include <stdio.h>

#ifndef RENDER_ENGINE_HPP
#define RENDER_ENGINE_HPP

typedef struct tagBITMAP
{
unsigned short width;
unsigned short height;
unsigned char pallete[256*3];
unsigned char * data;
}BITMAP;
Just a stab in the dark here, but your coding style indicates
you are writing a MS Windows application. MS Windows
header files already define "BITMAP". So if you include
this header after you have included windows.h etc. then
you might get that error.

Nov 29 '06 #9
Here my code (a simple program that put image on screen use SuperVGA
BGI Driver 600x480x256 colors mode):

File Const.h

#ifndef CONST_HPP_INCLUDED
#define CONST_HPP_INCLUDED
typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned long dword;

#define EXIT_SUCCESS 0
#define EXIT_FAILED 1
#define ERR_OPEN_FILE 2
#define ERR_MEM_ALLOC 3

#define BGI_DRIVER "SVGA64K"
#define BGI_600_480 4
#define BGI_COLORS 256
#define SCREEN_WIDTH 600
#define SCREEN_HEIGHT 480
#define PALLETE_INDEX 0x03c8
#define PALLETE_DATA 0x03c9
#define INPUT_STATUS 0x03da
#define VRETRACE 0x08

#define LOG_FILE_NAME "log.txt"

#endif
-------------
Render.h

#include <stdio.h>
#include "Const.h"

#ifndef RENDER_ENGINE_HPP
#define RENDER_ENGINE_HPP

typedef struct tagBITMAP
{
word width;
word height;
byte pallete[BGI_COLORS*3];
byte * data;
}BITMAP;

class CRender
{
public:
// Initialize graphic mode.
CRender();
~CRender();
void ClearScreen();
int GetLastError();
void WaitForRetrace(void);
void SetPalette(byte *palette);
void fskip(FILE * fp,int);
void PutImage (const char * filename,int x,int y,int ops) ;
private:
int m_iGDriver,m_iGMode,m_iErrorcode;

};

#endif
When i compile in BC++ 4.5 or TC++ 3.0, i got an error:
Error Render.h 15: Declaration syntax error.

Line 15 is line: " class CRender"

Thank for your help.

Nov 30 '06 #10

"tienlx" <ti*****@gmail.comwrote in message
news:11**********************@16g2000cwy.googlegro ups.com...
Here my code (a simple program that put image on screen use SuperVGA
BGI Driver 600x480x256 colors mode):

File Const.h

#ifndef CONST_HPP_INCLUDED
#define CONST_HPP_INCLUDED
typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned long dword;

#define EXIT_SUCCESS 0
#define EXIT_FAILED 1
#define ERR_OPEN_FILE 2
#define ERR_MEM_ALLOC 3

#define BGI_DRIVER "SVGA64K"
#define BGI_600_480 4
#define BGI_COLORS 256
#define SCREEN_WIDTH 600
#define SCREEN_HEIGHT 480
#define PALLETE_INDEX 0x03c8
#define PALLETE_DATA 0x03c9
#define INPUT_STATUS 0x03da
#define VRETRACE 0x08

#define LOG_FILE_NAME "log.txt"

#endif
-------------
Render.h

#include <stdio.h>
#include "Const.h"

#ifndef RENDER_ENGINE_HPP
#define RENDER_ENGINE_HPP

typedef struct tagBITMAP
{
word width;
word height;
byte pallete[BGI_COLORS*3];
byte * data;
}BITMAP;

class CRender
{
public:
// Initialize graphic mode.
CRender();
~CRender();
void ClearScreen();
int GetLastError();
void WaitForRetrace(void);
void SetPalette(byte *palette);
void fskip(FILE * fp,int);
void PutImage (const char * filename,int x,int y,int ops) ;
private:
int m_iGDriver,m_iGMode,m_iErrorcode;

};

#endif
When i compile in BC++ 4.5 or TC++ 3.0, i got an error:
Error Render.h 15: Declaration syntax error.

Line 15 is line: " class CRender"
What happens if you change BITMAP to spoo?
Maybe BITMAP is defined somewhere else.
(All caps are normally reserved for defines BTW)

How about if you remove the typedef for the struct
and do it like c++?

struct tagBitmap{...}

tagBitmap spoo;
....
Nov 30 '06 #11

Duane Hebert wrote:
"tienlx" <ti*****@gmail.comwrote in message
news:11**********************@16g2000cwy.googlegro ups.com...
Here my code (a simple program that put image on screen use SuperVGA
BGI Driver 600x480x256 colors mode):

File Const.h

#ifndef CONST_HPP_INCLUDED
#define CONST_HPP_INCLUDED
typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned long dword;

#define EXIT_SUCCESS 0
#define EXIT_FAILED 1
#define ERR_OPEN_FILE 2
#define ERR_MEM_ALLOC 3

#define BGI_DRIVER "SVGA64K"
#define BGI_600_480 4
#define BGI_COLORS 256
#define SCREEN_WIDTH 600
#define SCREEN_HEIGHT 480
#define PALLETE_INDEX 0x03c8
#define PALLETE_DATA 0x03c9
#define INPUT_STATUS 0x03da
#define VRETRACE 0x08

#define LOG_FILE_NAME "log.txt"

#endif
-------------
Render.h

#include <stdio.h>
#include "Const.h"

#ifndef RENDER_ENGINE_HPP
#define RENDER_ENGINE_HPP

typedef struct tagBITMAP
{
word width;
word height;
byte pallete[BGI_COLORS*3];
byte * data;
}BITMAP;

class CRender
{
public:
// Initialize graphic mode.
CRender();
~CRender();
void ClearScreen();
int GetLastError();
void WaitForRetrace(void);
void SetPalette(byte *palette);
void fskip(FILE * fp,int);
void PutImage (const char * filename,int x,int y,int ops) ;
private:
int m_iGDriver,m_iGMode,m_iErrorcode;

};

#endif
When i compile in BC++ 4.5 or TC++ 3.0, i got an error:
Error Render.h 15: Declaration syntax error.

Line 15 is line: " class CRender"

What happens if you change BITMAP to spoo?
Maybe BITMAP is defined somewhere else.
(All caps are normally reserved for defines BTW)

How about if you remove the typedef for the struct
and do it like c++?

struct tagBitmap{...}

tagBitmap spoo;
...

I tried, but it does'nt work.

Nov 30 '06 #12

"tienlx" <ti*****@gmail.comwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
When i compile in BC++ 4.5 or TC++ 3.0, i got an error:
Error Render.h 15: Declaration syntax error.

Line 15 is line: " class CRender"

What happens if you change BITMAP to spoo?
Maybe BITMAP is defined somewhere else.
(All caps are normally reserved for defines BTW)

How about if you remove the typedef for the struct
and do it like c++?

struct tagBitmap{...}

tagBitmap spoo;
...


I tried, but it does'nt work.
Then I'm out of ideas. You typically get this
sort of error when a preceding declaration is
not terminated properly, for example, an
included header with a class declaration missing
the ;
Nov 30 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: crichmon | last post by:
Any general advice for dealing with circular dependencies? For example, I have a situation which, when simplified, is similar to: ///////////// // A.h class A { public: int x;
9
by: Koster | last post by:
Something I've been puzzled over for a while. This really has no consequence at all, but I'm curious for the _reason_ behind where we commonly place the asterisk when declaring pointer variables....
4
by: j0mbolar | last post by:
What is the chapter and verse for the following? #include <stdio.h> void foo(struct bar *baz); struct bar { int x, y; };
3
by: Edward Diener | last post by:
In the doc regarding __value classes, under Primitive Types, I read: "Generally, the C++ types and their __value class equivalents are interchangeable in Managed Extensions." What exactly does...
1
by: louis_la_brocante | last post by:
Dear all, I am having trouble generating a client proxy for a webservice whose methods return a "complex" type. The type is complex in that it is a class whose members are a mix of primitive...
20
by: pinkfloydhomer | last post by:
Is it well-defined and portable to do something like: typedef struct { int type; char c; } S1; typedef struct {
58
by: jacob navia | last post by:
Hi people I have been working again in my tutorial, and I have finished the "types" chapter. If you feel like "jacob bashing" this is the occasion! I am asking for criticisms, or for things I may...
14
by: Lane Straatman | last post by:
I would like to write a 'struct'. I have a library that is all but completely inappropriate for this task. So I'm looking for C code that fills in the gaps between: #undef...
12
by: Michael.Z | last post by:
Anyone who can help: Given a Table.h file I am writing a Table.c file. I keep getting the compile error: previous declaration of Table was here / conflicting types for I think the...
3
by: SRoubtsov | last post by:
Dear all, Do you know whether ANSI C (or some other dialects) support the following: * a variable name coincides with a type name, * a structure/union field name coincides with a type name in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.