[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Parallella Community • View topic - C++ with GCC: optimizing for size

C++ with GCC: optimizing for size

Discussion about Parallella (and Epiphany) Software Development

Moderators: amylaar, jeremybennett, simoncook

C++ with GCC: optimizing for size

Postby Gravis » Fri Oct 24, 2014 6:07 pm

User avatar
Gravis
 
Posts: 445
Joined: Mon Dec 17, 2012 3:27 am
Location: East coast USA.

Re: C++ with GCC: optimizing for size

Postby jeremybennett » Sun Oct 26, 2014 5:09 pm

Hi Gravis,

All fair comments. C++ is inherently a bigger language than C - it's only just possible on Epiphany. You really are better sticking to C.

I'm not sure how much the inline keyword will do for you. It is advisory only. You are probably better looking at the command line options which control inlining.

Its not at all unusual to get smaller code with -O1 than -Os. -Os is just -O2 with a few optimizations that tend to increase size disabled. There is no GCC equivalent of LLVM's -Oz.
User avatar
jeremybennett
 
Posts: 61
Joined: Mon Dec 17, 2012 9:06 am

Re: C++ with GCC: optimizing for size

Postby Gravis » Tue Oct 28, 2014 10:08 am

User avatar
Gravis
 
Posts: 445
Joined: Mon Dec 17, 2012 3:27 am
Location: East coast USA.

Re: C++ with GCC: optimizing for size

Postby notzed » Tue Oct 28, 2014 10:16 pm

C++ isn't just C with "simpler syntax" (rofl), it's a completely different language. Historical evidence (and indeed, your complaints) suggests it's also a very bulky one.
notzed
 
Posts: 331
Joined: Mon Dec 17, 2012 12:28 am
Location: Australia

Re: C++ with GCC: optimizing for size

Postby Gravis » Wed Oct 29, 2014 12:51 pm

User avatar
Gravis
 
Posts: 445
Joined: Mon Dec 17, 2012 3:27 am
Location: East coast USA.

Re: C++ with GCC: optimizing for size

Postby jeremybennett » Wed Oct 29, 2014 4:32 pm

Hi notzed, Gravis,

C++ is truly a separate language, it draws its inspiration from two languages, C (of course) and Simula 67. Which is why C++ compilers are not just pre-processors for C.

C++ defines a richer semantics, and implementing that richer semantics will often result in larger code. However if you keep to C like semantics, then on the whole the code size will be the same, as Gravis found out.

The real killer for C++ is that it defines a very large standard libary (the STL). This is where your really big memory growth will happen.

Just one thing to correct from an earlier comment. You can implement an OO design in C, you just need to follow suitable coding discipline. It is quite common to use UML when designing and then implement in C. However C++ provides linguistic structures to make OO coding easier, and these can sometimes prove more efficient when compiled than writing the implementation in C.

HTH,


Jeremy
User avatar
jeremybennett
 
Posts: 61
Joined: Mon Dec 17, 2012 9:06 am

Re: C++ with GCC: optimizing for size

Postby xilman » Sun Nov 02, 2014 8:33 pm

xilman
 
Posts: 80
Joined: Sat May 10, 2014 8:10 pm
Location: UK

Re: C++ with GCC: optimizing for size

Postby notzed » Sun Nov 02, 2014 10:00 pm

notzed
 
Posts: 331
Joined: Mon Dec 17, 2012 12:28 am
Location: Australia

Re: C++ with GCC: optimizing for size

Postby etim » Tue Sep 29, 2015 12:32 pm

How do you exactly go about reducing the size of the compiled program? The hello-world example () compiles down to a 39KB ELF file. I'm a complete newbie and would love some direction. Thanks!
etim
 
Posts: 22
Joined: Sat Jun 27, 2015 6:08 pm


Return to Programming Q & A

Who is online

Users browsing this forum: No registered users and 4 guests