lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sat, Dec 20, 2008 at 2:24 PM, Eric Tetz <erictetz@gmail.com> wrote:
> pan shizhu <pan.shizhu@gmail.com> wrote:
>> xxd -i output a char array like the following, which is not a string
>> literal.
>>
>> unsigned char ltools_lua[] = {
>>   0x0a, 0x6c, 0x6f, 0x63, 0x61,
>> };
>
> That's similar to what Dave was pointing out earlier:
>
>   const char* s = "foo...bar";  /* string literal; limited to 4096 */
>   const char s[] = "foo...bar"; /* initializer, NOT a string literal */

Except that the initializer does come from a string literal, to which
the limit applies.  C (or C++) implementations don't even have to
accept tokens that are too long, however they may be used.

> The latter is equivalent to:
>
>   const char s[] = { 'f', 'o', 'o', ... 'b', 'a', 'r' };

Except for (a) the length limit on string literals and (b) trivially,
the missing NUL terminator.

-- James