Re: [arm-gnu] int32_t != int?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [arm-gnu] int32_t != int?
- To: arm-gnu@xxxxxxxxxxxxxxxx
- Subject: Re: [arm-gnu] int32_t != int?
- From: Kishore <kitts.mailinglists@xxxxxxxxx>
- Date: Wed, 15 Jul 2009 18:37:21 +0530
On Wednesday 15 Jul 2009 9:47:32 am Mark Mitchell wrote:
> Kishore wrote:
> > Why is g++ not making the right choice and implicitly considering int32_t
> > to be an ordinary int? I can construct a simple example to demonstrate
> > this if needed.
>
> Yes, you should post an example.
The following is the sample code
test.cpp :
#include <inttypes.h>
class MyClass
{
public:
int64_t m_val;
MyClass(int val){m_val = val;}
MyClass(unsigned int val){m_val = (int64_t)val;}
//The following two constructors give an error when used with native g++ compiler Their absence is a problem for arm-none-eabi-g++
// MyClass(int32_t val){m_val = val;}
// MyClass(uint32_t val){m_val = (int64_t)val;}
};
main()
{
int32_t value = 45;
MyClass myClass(value);
while(1);
}
-----------------------------
Native g++ wont compile with those two constructors and arm-none-eabi-g++ will not compile without them! Here is the output.
kishore@Lucifer:~$ g++ test.cpp
test.cpp:12: error: ‘MyClass::MyClass(int32_t)’ cannot be overloaded
test.cpp:8: error: with ‘MyClass::MyClass(int)’
test.cpp:13: error: ‘MyClass::MyClass(uint32_t)’ cannot be overloaded
test.cpp:9: error: with ‘MyClass::MyClass(unsigned int)’
kishore@Lucifer:~$ export PATH=$PATH:~/Downloads/arm-2009q1/bin
kishore@Lucifer:~$ arm-none-eabi-g++ test.cpp
/home/kishore/Downloads/arm-2009q1/bin/../lib/gcc/arm-none-eabi/4.3.3/../../../../arm-none-eabi/bin/ld: warning: cannot find entry symbol _start; defaulting to 00008018
//Here i comment out the two fixed width constructors
kishore@Lucifer:~$ arm-none-eabi-g++ test.cpp
test.cpp: In function 'int main()':
test.cpp:20: error: call of overloaded 'MyClass(int32_t&)' is ambiguous
test.cpp:9: note: candidates are: MyClass::MyClass(unsigned int)
test.cpp:8: note: MyClass::MyClass(int)
test.cpp:5: note: MyClass::MyClass(const MyClass&)
kishore@Lucifer:~$
Please ignore the linker warning here. I have not explicitly mentioned a liker script for this example.
--
Cheers!
Kishore