Page 1 of 1

redefinition of typedef 'u*' in System.h

Posted: Wed Oct 15, 2008 4:36 am
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.


redefinition of typedef 'u*' in System.h

Posted: Wed Oct 15, 2008 8:53 am
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).


redefinition of typedef 'u*' in System.h

Posted: Thu Oct 16, 2008 7:47 am
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" />


redefinition of typedef 'u*' in System.h

Posted: Thu Oct 16, 2008 3:02 pm
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.