On Mon, Jun 27, 2011 at 6:33 PM, Mike Frysinger <[email protected]> wrote:
> On Monday, June 27, 2011 18:21:31 Jie Zhang wrote:
>> On Mon, Jun 27, 2011 at 5:45 PM, Mike Frysinger wrote:
>> > On Friday, June 24, 2011 10:39:29 Jie Zhang wrote:
>> >> On Fri, Jun 17, 2011 at 4:39 PM, Mike Frysinger wrote:
>> >> > On Friday, June 17, 2011 16:09:47 Jie Zhang wrote:
>> >> >> On Fri, Jun 17, 2011 at 1:58 PM, Mike Frysinger wrote:
>> >> >> >> +    const char *ex_short = "[firmware=FILE]";
>> >> >> >> +    const char *ex_desc = "FILE       Upgrade the ICE firmware.
>> >> >> >>  See this
>> >> >> >
>> >> >> > page:\n"
>> >> >> >
>> >> >> > const char foo[] = "..."
>> >> >>
>> >> >> Why?
>> >> >
>> >> > one less pointer.  compare the assembly output:
>> >> > $ echo 'const char foo[] = "asdf";' | gcc -S -o - -x c -
>> >> > $ echo 'const char *foo = "asdf";' | gcc -S -o - -x c -
>> >>
>> >> But when it's passed as an argument, the former will pass the whole
>> >> string but the latter will only pass a pointer.
>> >
>> > no it wont.  in both cases, passing it as an argument will pass a
>> > pointer.
>>
>> On x86_64-linux-gnu host with -O2, the former:
>
> it's simply using the stack as temporary storage.  it isnt passing it to the
> func.  i guess you'd also need "static" to make it use .rodata.
>
Yes adding "static" makes the code looks same as just using pointer.
Then why not just using pointer?

Anyway what you pointed out with this example

>> >> > $ echo 'const char foo[] = "asdf";' | gcc -S -o - -x c -
>> >> > $ echo 'const char *foo = "asdf";' | gcc -S -o - -x c -
> one less pointer.

does not hold when "foo" is defined in a function.


Jie

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
UrJTAG-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/urjtag-development

Reply via email to