| View previous topic :: View next topic |
| Author |
Message |
asphodeli
Joined: 29 Jun 2008 Posts: 20 Location: Singapore
|
Posted: Fri Oct 24, 2008 12:55 am Post subject: Compiler error? Ambiguous types |
|
|
Hi all,
I'm trying to port over a game engine, and it compiles fine as a library, but when I try out the sample code, i get the error:
| Code: | psp-g++ -I-I -I../../include/ -I. -I/usr/local/pspdev/psp/sdk/include -G0 -O2 -I-I -I../../include/ -I. -I/usr/local/pspdev/psp/sdk/include -G0 -O2 -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=390 -c -o main.o main.cpp
In file included from /usr/local/pspdev/psp/sdk/include/pspuser.h:18,
from /usr/local/pspdev/psp/sdk/include/pspkernel.h:18,
from main.cpp:79:
/usr/local/pspdev/psp/sdk/include/psptypes.h:68: error: reference to ‘u8’ is ambiguous
/usr/local/pspdev/psp/sdk/include/psptypes.h:39: error: candidates are: typedef uint8_t u8
|
Any ideas?
Last edited by asphodeli on Fri Oct 24, 2008 7:41 pm; edited 1 time in total |
|
| Back to top |
|
 |
Onii
Joined: 05 Oct 2008 Posts: 40
|
Posted: Fri Oct 24, 2008 9:45 am Post subject: |
|
|
Sounds like u8 is defined more than once. Check all your includes for definitions of u8.
Odd though that it only shows one candidate. Are you using any other high level libraries that might define u8 like psptypes.h does?
Another thing I notice is this is a cpp file. Are the others that compile also cpp or just c? |
|
| Back to top |
|
 |
asphodeli
Joined: 29 Jun 2008 Posts: 20 Location: Singapore
|
Posted: Fri Oct 24, 2008 7:47 pm Post subject: |
|
|
| Everything else is in cpp (if you're talking about just the sample code with the compiled library) , and yes I am using a custom defined typedef that is provided by the game engine. My output from psp-g++ is listed on http://pastebin.com/m1c4fa721 for brevity's sake |
|
| Back to top |
|
 |
Onii
Joined: 05 Oct 2008 Posts: 40
|
Posted: Sat Oct 25, 2008 8:00 am Post subject: |
|
|
psptypes.h defines a u8 typedef. If your library also defines one, you'll need to comment one or the other out (or wrap them in #ifdefs) so that you only have one definition.
EDIT: Or of course, if it's defined in a class use Class::u8. same if you are "using Namespace;" |
|
| Back to top |
|
 |
asphodeli
Joined: 29 Jun 2008 Posts: 20 Location: Singapore
|
Posted: Sat Oct 25, 2008 9:57 am Post subject: |
|
|
| Onii wrote: | psptypes.h defines a u8 typedef. If your library also defines one, you'll need to comment one or the other out (or wrap them in #ifdefs) so that you only have one definition.
EDIT: Or of course, if it's defined in a class use Class::u8. same if you are "using Namespace;" |
Well, the strange thing is that my custom u8 is inside a namespace, and somehow it conflicts with psptypes.h:
| Code: |
namespace TestEngine
{
typedef unsigned char u8;
}
|
|
|
| Back to top |
|
 |
Onii
Joined: 05 Oct 2008 Posts: 40
|
Posted: Sat Oct 25, 2008 10:05 am Post subject: |
|
|
Yes, and you are likely doing "using TestEngine;", therefore colliding your name space with global.
Just qualify your declarations with TestEngine::u8 var; and you'll be fine. |
|
| Back to top |
|
 |
asphodeli
Joined: 29 Jun 2008 Posts: 20 Location: Singapore
|
Posted: Sat Oct 25, 2008 10:17 am Post subject: |
|
|
| Onii wrote: | Yes, and you are likely doing "using TestEngine;", therefore colliding your name space with global.
Just qualify your declarations with TestEngine::u8 var; and you'll be fine. |
Whoa...thats alot of work...if its the only way then there isn't much choice, but the code compiles fine on the linux version of gcc with no complaints, so I asked the question. :) |
|
| Back to top |
|
 |
Onii
Joined: 05 Oct 2008 Posts: 40
|
Posted: Sat Oct 25, 2008 10:37 am Post subject: |
|
|
Or you can comment the declaration out of psptypes.h.
EDIT: of course.... that's a whole other can of worms :)
EDIT: global search and replace, with confirmation is your friend :) |
|
| Back to top |
|
 |
|