Compiler error? Ambiguous types

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
asphodeli
Posts: 20
Joined: Sun Jun 29, 2008 2:44 pm
Location: Singapore

Compiler error? Ambiguous types

Post by asphodeli »

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: Select all

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.
Onii
Posts: 40
Joined: Sun Oct 05, 2008 1:07 pm

Post by Onii »

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?
asphodeli
Posts: 20
Joined: Sun Jun 29, 2008 2:44 pm
Location: Singapore

Post by asphodeli »

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
Onii
Posts: 40
Joined: Sun Oct 05, 2008 1:07 pm

Post by Onii »

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;"
asphodeli
Posts: 20
Joined: Sun Jun 29, 2008 2:44 pm
Location: Singapore

Post by asphodeli »

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: Select all

namespace TestEngine
{
typedef unsigned char		u8;
}
Onii
Posts: 40
Joined: Sun Oct 05, 2008 1:07 pm

Post by Onii »

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.
asphodeli
Posts: 20
Joined: Sun Jun 29, 2008 2:44 pm
Location: Singapore

Post by asphodeli »

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. :)
Onii
Posts: 40
Joined: Sun Oct 05, 2008 1:07 pm

Post by Onii »

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 :)
Post Reply