#85324 - Dannon - Mon May 29, 2006 12:52 am
I am getting 2 errors for my input file when I compile:
error: redefinition of 'class CInput'
error: previous definition of 'class CInput'
These errors are in reference to the:
This is the code that I have in my input_ds.h:
Code: |
#include <nds.h>
class CInput
{
public:
CInput();
~CInput();
bool Initialise();
};
|
Any suggestions as to the problem, it's normally something really simple.
#85326 - MrD - Mon May 29, 2006 1:30 am
You might need to add some multiple-inclusion safeguards, to stop the file containing your class description from being included more than once:
Code: |
#ifndef CINPUT_H
#define CINPUT_H
#include <nds.h>
class CInput
{
public:
CInput();
~CInput();
bool Initialise();
};
#endif /* CINPUT_H */ |
_________________
Not active on this forum. For Lemmings DS help see its website.
#85327 - Dannon - Mon May 29, 2006 1:48 am
Thanks, I think that got it.
Now I have a completely different error though, on my 'class CInput' line as shown in my previous code, as well as some others such as the Initialise function in main.c and the 'class CDisplay' line at the top of the display.h file, I am getting an error which says:
error: expected '=', ',', ', ', ;', 'asm', '__attribute__' before 'CInput'
#85331 - MrD - Mon May 29, 2006 2:16 am
That error usually means that it hasn't recognised one of the tokens as a valid type. You can get that error if you do something like this:
Code: |
struct Player {
int x,y;
};
Player dave; |
... when compiling under a strict C standard.
Just a guess, but try changing your class header file's extension from .h to .hpp.
Edit - The error might be because your main source file is a .c file, and you're trying to use the C++ classes feature. Try changing the class header to .hpp and the main source to main.cpp
_________________
Not active on this forum. For Lemmings DS help see its website.
#85342 - Dannon - Mon May 29, 2006 4:22 am
Changing my main.c to .cpp did it.
Thanks a lot, all problems, for the moment, solved.
--Dannon
#85598 - Dannon - Thu Jun 01, 2006 5:27 am
More complaints from the compiler, it has started complaining about the ds variable types in some of my files such as v16, u32, u8. It also comes up with the some errors for nds/arm9/console.h so I'm wondering if there is some kind of linking error, I have tried putting libnds back again but it did nothing. Any help?
--Dannon
#85606 - MrD - Thu Jun 01, 2006 9:12 am
Can you paste the errors?
_________________
Not active on this forum. For Lemmings DS help see its website.
#85619 - wintermute - Thu Jun 01, 2006 11:08 am
Dannon wrote: |
More complaints from the compiler, it has started complaining about the ds variable types in some of my files such as v16, u32, u8. It also comes up with the some errors for nds/arm9/console.h so I'm wondering if there is some kind of linking error, I have tried putting libnds back again but it did nothing. Any help?
|
You're probably using an old makefile, grab one from the latest examples.
for reference you should have
Code: |
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
in the makefile
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog
#85682 - Dannon - Thu Jun 01, 2006 7:55 pm
Code: |
./arm9/source/displayEntityModel_ds.h:18: error 'v16' has not been declared'
./arm9/source/displayEntityModel_ds.h:18: error 'u32' has not been declared'
./arm9/source/displayEntityModel_ds.h:18: error 'u32' has not been declared'
./arm9/source/displayEntityModel_ds.h:18: error 'u32' has not been declared'
./arm9/source/displayEntityModel_ds.h:20: error 'v16' has not been declared'
./arm9/source/world.cpp:157: error: 'class CInput' has no member named 'm_touchReadXY'
./arm9/source/world.cpp:157: error: 'class CInput' has no member named 'm_touchReadXY'
|
This continues for any reference to v16, u16, u32, u8 throughout my code.
Code: |
./nds/arm9/console.h:33: error 'touchPosition' does not name a type
./nds/arm9/console.h:42: error 'touchPosition' does not name a type
./nds/arm9/console.h:94: error 'u16' was not declared in this scope
./nds/arm9/console.h:94: error 'font' was not declared in this scope
./nds/arm9/console.h:94: error 'u16' was not declared in this scope
./nds/arm9/console.h:94: error 'charBase' was not declared in this scope
./nds/arm9/console.h:94: error 'u16' was not declared in this scope
./nds/arm9/console.h:94: error 'u8' was not declared in this scope
./nds/arm9/console.h:94: error 'u16' was not declared in this scope
./nds/arm9/console.h:94: error 'map' was not declared in this scope
./nds/arm9/console.h:94: error 'u8' was not declared in this scope
./nds/arm9/console.h:94: error 'u8' was not declared in this scope
./nds/arm9/console.h:94: error: initializer expression list treated as compound void
./nds/arm9/console.h:104: error: variable of field 'consoleInitDefault' declared void
./nds/arm9/console.h:104: error 'u16' was not declared in this scope
./nds/arm9/console.h:104: error 'map' was not declared in this scope
./nds/arm9/console.h:104: error 'u16' was not declared in this scope
./nds/arm9/console.h:104: error 'charBase' was not declared in this scope
./nds/arm9/console.h:104: error 'u8' was not declared in this scope
./nds/arm9/console.h:104: error: initializer expression list treated as compound void
|
I tried appending the makefile but it didn't seem to make any bit of difference.
Any other suggestions?
--Dannon
#85701 - wintermute - Thu Jun 01, 2006 10:02 pm
Dannon wrote: |
[code]
I tried appending the makefile but it didn't seem to make any bit of difference.
|
appending the makefile?
There's something very, very wrong with your build setup somewhere.
Try *replacing* your makefile with one of the standard ones from recent examples.
This looks like nds.h is not being included.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog
#85732 - silent_code - Fri Jun 02, 2006 2:07 am
hi,
first thing: you don'T have to make these #ifndefs and stuff, just make sure you have a #pragma once on top of each header file. this is just an alternative (and it works).
second issue looks like you missed to include the nds.h file... or something went really wrong with you make setup (as the others already said). try compiling one of the emapbles and then grab that makefile from it... but check if the nds.h is accessable from all .cpp files where it's needed! also look for include orders and the like!
Rob
#85739 - tepples - Fri Jun 02, 2006 2:48 am
silent_code wrote: |
first thing: you don'T have to make these #ifndefs and stuff, just make sure you have a #pragma once on top of each header file. this is just an alternative (and it works). |
#pragma once is not portable. If you switch compilers, or you switch versions of your compiler, your #pragmas may stop working. Always use #ifdef guards for multiple inclusion.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#85751 - silent_code - Fri Jun 02, 2006 4:34 am
as stated before: it's an alternative... well, i should have said that it depends on the compiler to support it. thanks tepples :)
it works well with gcc (and i think i remember ms vs6) and being a lazy person i use it for every header file i write. i find those ifndefs horrible.
though you're right, it can save you some work when switching compilers for a project. well, i won't switch ;p
#85754 - Dannon - Fri Jun 02, 2006 5:02 am
Right then, I have uploaded my code to: http://dannons.50megs.com/index.html, just click the link on the page.
It should currently be just displaying what buttons are being pressed and not being pressed, a bit of a glorified Hello World really, not very exciting but it's just a start, I am attempting a simple 3D engine with simple physics so this is me starting to setup all of my classes, etc.
If I could also get a little feedback on how this setup would work on the DS, can the DS handle vector lists? Any other feedback would be greatly appreciated
--Dannon
#85756 - silent_code - Fri Jun 02, 2006 5:05 am
what do you mean by vector lists... i know what they are, but what you want to use them for?
#85757 - silent_code - Fri Jun 02, 2006 5:20 am
dude, i checked it... i didn't look through all files, but the ones that yield the errors and i must admit that i can't find anything wrong. must be something quitte "special". i compared it to my projects (that all compile without error...) and the only difference is the directory layout. i use a source, a build, a data and an include dir. i also use the standard makefile. you seem to use the template, so that shouldn't be the point. i'd have to get a second look. don't know when i'll find some time for it, but it's quite an interesting thing.
i'd really like to know why this happens.
#85788 - wintermute - Fri Jun 02, 2006 10:55 am
from world.cpp
Code: |
1 //////////
// world.cpp
// --Dannon
//
#include "world.h"
#include "input_ds.h"
#include "display_ds.h"
#include <nds.h>
#include <nds/arm9/console.h>
#include <stdio.h>
|
Note the spurious first line which appears to be the source of your errors. You should also get into the habit of including nds.h first. This is where the nds type definitions are included from.
Code: |
//////////
// world.cpp
// --Dannon
//
#include <nds.h>
#include <stdio.h>
#include "world.h"
#include "input_ds.h"
#include "display_ds.h"
|
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog
#85802 - silent_code - Fri Jun 02, 2006 12:39 pm
i checked that, didn't work!? no change at all...
he used to include the nds.h nearly everywhere, still it won't compile.
#85841 - wintermute - Fri Jun 02, 2006 4:01 pm
No idea what to say.
The project compiled for me with that modification ( and the addition of a standard arm7 core - you seem to have missed the code for that in the archive )
Are you absolutely sure you modified the right source file?
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog
#86063 - Dannon - Sun Jun 04, 2006 3:54 am
It's all working fine now, I am such a retard sometimes when it comes to coding all my problems are always just over looked simple ones, anyway it was sorted pretty quickly, I have upgraded to R19 of devkitARM too and still no problems. I noticed the arm7 code was missing I have no idea where it went, I just copied the one from the template.
I have another question now though, I have managed to get some 3D going now, but if I want to start it I have to start my program in 3D mode, I use the following code:
Code: |
bool CDisplay::InitialiseInGame()
{
powerON( POWER_ALL );
videoSetMode(MODE_0_3D);
videoSetModeSub( MODE_0_2D | DISPLAY_BG0_ACTIVE );
SUB_BG0_CR = BG_MAP_BASE(31);
BG_PALETTE_SUB[255] = RGB15(31,31,31);
// Temp
consoleInitDefault( (u16*)SCREEN_BASE_BLOCK_SUB( 31 ), (u16*)CHAR_BASE_BLOCK_SUB( 0 ), 16 );
irqInit();
irqEnable(IRQ_VBLANK);
glViewPort(0,0,255,191);
glClearColor(0,0,0);
glClearDepth(0x7FFF);
return true;
}
|
Is there a way to switch the screen to using 3D so that I can jump from menu (all 2D from the simple graphics demos) to using 3D on the top screen, powerSET maybe?, and how do I get the console to run on the lower screen at the same time, do I need some more setup lines than above?
Thanks for all the help.
--Dannon