Andes Workshop

It is currently Mon Jun 26, 2017 12:50 pm

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Global object constructor is not called
PostPosted: Thu Apr 17, 2014 3:17 pm 
Offline

Joined: Thu Jan 23, 2014 4:18 pm
Posts: 12
Code:
class Test {
public:
   int id;
   Test (int newid) : id(newid) {}
};
Test Test1(123);

int main ()
{
   printf ("%d\n", Test1.id);
}

在dev-c++執行時,可以正常的印出123。
但是用Andesight,會印出0 (因為Test1放在bss section),沒有呼叫constructor。

這個問題的目的,是希望能建立global object with constant member。例如:
Code:
class Test {
public:
   const int id;
   Test (int newid) : id(newid) {}
};
Test Test1(1), Test2(2), Test3(3);


Top
 Profile  
 
 Post subject: Re: Global object constructor is not called
PostPosted: Mon Apr 21, 2014 12:05 pm 
Offline

Joined: Thu Apr 03, 2014 10:09 am
Posts: 42
Hi banyh,

http://stackoverflow.com/questions/22130402/can-gcc-optimize-methods-of-a-class-with-compile-time-constant-variables

this question is the same at URL,

GCC 4.7 will support the "constexpr " , but andes toolchain is based on GCC 4.4.4.

The Andes toolchain will be update GCC version at the future.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group