redefinition of typedef 'u*' in System.h

This particular forum is archives, bug reports should be made at https://github.com/visualboyadvance-m/v ... e-m/issues


Post Reply
KunaiTeam
Junior Member
Posts: 44
Joined: Thu Aug 14, 2008 9:37 pm

redefinition of typedef 'u*' in System.h

Post by KunaiTeam »

The one bug I found while developing my frontend is that System.h has multiple typedefs for u8, u16 and u32. The first set uses the stdint types, and the second uses "unsigned char" etc. For some reason this compiles fine with CMake, but I couldn't for the life of me get it to compile with GCC 4. It kept giving me errors like "Redefinition of typedef 'u8'". I just deleted the extras from System.h and it worked fine, but I just now remembered it. I didn't report it because it's acceptable in C++, but it still seems weird to me. For reference, the code in question is

 

Code: Select all

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;

...

typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;

 

That second set will fail anyway if sizeof int is != 4. It seems a little silly to be using these abbreviations since stdint.h is part of C99, though I realize that may not have been the case when VBA was first developed. Perhaps this is something we could flag for a core rewrite?

 

EDIT: I forgot why I didn't report it earlier, and now I have remembered.

Last edited by KunaiTeam on Wed Oct 15, 2008 4:42 am, edited 1 time in total.
spacy51
Senior Member
Posts: 371
Joined: Tue Mar 18, 2008 4:59 pm

redefinition of typedef 'u*' in System.h

Post by spacy51 »

The one bug I found while developing my frontend is that System.h has multiple typedefs for u8, u16 and u32. The first set uses the stdint types, and the second uses "unsigned char" etc. For some reason this compiles fine with CMake, but I couldn't for the life of me get it to compile with GCC 4. It kept giving me errors like "Redefinition of typedef 'u8'". I just deleted the extras from System.h and it worked fine, but I just now remembered it. I didn't report it because it's acceptable in C++, but it still seems weird to me. For reference, the code in question is

 

Code: Select all

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;

...

typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;

<div>

 

That second set will fail anyway if sizeof int is != 4. It seems a little silly to be using these abbreviations since stdint.h is part of C99, though I realize that may not have been the case when VBA was first developed. Perhaps this is something we could flag for a core rewrite?

 

EDIT: I forgot why I didn't report it earlier, and now I have remembered.

</div>

 

Thank you for the info. I will clean that up as soon as I am back on Windows (some days).

spacy51
Senior Member
Posts: 371
Joined: Tue Mar 18, 2008 4:59 pm

redefinition of typedef 'u*' in System.h

Post by spacy51 »

DONE

 

Removed the three lines.

stdint.h is shipped with VBA-M because MSVC does not support C99 [img]<fileStore.core_Emoticons>/emoticons/huh.png[/img]/emoticons/huh@2x.png 2x" width="20" height="20" />

KunaiTeam
Junior Member
Posts: 44
Joined: Thu Aug 14, 2008 9:37 pm

redefinition of typedef 'u*' in System.h

Post by KunaiTeam »

Not only does MSVC not support C99, but Microsoft has stated that they have no plans to support it. Luckily stdint.h is easy to reproduce, but that ended up being a real headache for me about a year ago when I was porting a large C99 project to Windows.

Post Reply