Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
공지
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Abstract Classes in Nios C++

Altera_Forum
명예로운 기여자 II
1,304 조회수

Hello, 

 

I am trying to implement abstract classes using gnupro C++ for nios and cyclone. 

 

Comparing the results using inheritance - and doing wrong - and the virtual keyword - and doing right - in the same code, the code which uses virtual keyword is 15 times bigger. 

 

Does anyone have done something optimized using abstract classes in Nios? 

 

Thanks, 

 

Flavio
0 포인트
1 응답
Altera_Forum
명예로운 기여자 II
507 조회수

I assume by "abstract classes" you mean classes with pure virtual methods (e.g. virtual int foo() = 0). 

 

If you are linking with libstdc++, it could be that a large chunk of exception handling code is being included (I&#39;ve found operator new & delete particularly bad for this and always override them). Have a look at your linker map (if you&#39;re not generating one, add "-Map <filename>" to your linker flags) for any evidence of this. Compiler options "-fno-exceptions" and "-fno-rtti" help greatly in keeping EC++ code size down (assuming you&#39;re not actually using exceptions and run-time type info!). 

 

The code for virtual classes will be bigger due their vtables etc, but not by a factor of 15 (unless the non-virtual ones were very small and numerous). 

 

If your classes really are abstract, try stubbing out the "__cxa_pure_virtual()" function as follows: 

 

extern "C" void __cxa_pure_virtual() 

 

 

Steve.
0 포인트
응답