lkml.org 
[lkml]   [2005]   [Feb]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [2.6 patch] drivers/net/smc-mca.c: cleanups
Date
Arjan van de Ven <arjan@infradead.org> wrote:
>
>> I've used this technique in a few very
>> small programs to reduce their size (I could strip off both their bss and
>> data sections to save space). Also, I believe that the compiler is able
>> to optimize code using consts, but this is pure speculation, I've not
>> verified it.
>
> Afaik that's the main difference between C and C++; in C you can still
> change "const" variables... in C++ thats illegal (at least that's what I
> remember and google seems to support somewhat ;)

The compiler does use the const modifier on a static object to optimise
code. Try compiling this program:

const int x;

int bar(int);

int foo(void)
{
bar(x);
return bar(x);
}

With the const gcc (3.3.4) will only load x once while it'll reload
it after calling bar if you remove the const modifier.
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:10    [W:1.268 / U:0.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site