strings and constness
Jason Schoon
floydpink at gmail.com
Sun Jun 18 17:45:13 UTC 2006
On 6/18/06, Rob Landley <rob at landley.net> wrote:
>
>
> Yeah. Avoid using const.
>
> I just threw "#define const" at the top of libbb.h, and fixed up half a
> dozen
> files that broke when I did that (because they didn't #include libbb.h at
> the
> top), and the result was actually 1500 bytes _smaller_. By not having
> anything say const anywhere. (The resulting binary was about 2k smaller
> as
> well.)
>
> Just FYI. With gcc 4.0.3.
>
> > E
>
> Rob
> --
> Never bet against the cheap plastic solution.
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox
>
Running a very similar test with gcc 3.3.4 on x86 (Built clean using
defconfig, then added #define const to the top of libbb.h, then rebuilt
defconfig clean once more, fixing up the few places where header ordering
had caused an error), I actually ended up with a binary that was 14k
smaller.
If const were actually an enforced type in a strongly-typed language, I
might have concern about removing it. However, given that anybody can
simply ignore the const by casting, and that it appears to increase binary
size, not to mention causing unnecessary code fixups, I say whack it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.busybox.net/pipermail/busybox/attachments/20060618/4e945334/attachment-0001.htm
More information about the busybox
mailing list