On 9/7/10 2:01 PM, Dmitry Shulga wrote:
> Hi Davi!
>> On 9/7/10 1:34 AM, Dmitry Shulga wrote:
>>>>> + MYSQL_RES *res;
>>>>>>> + MYSQL_BIND bind; + int rc; + const
>>>>>>> char* sql_select = "SELECT 1, 'a'";
>>>>> const char sql_select= "SELECT 1, 'a'";
>>> Left as is since const char* is better type for a character
>> sql_select in your patch is just a pointer, whereas what I
>> suggested is a array. A array is certainly a "better" type to hold
>> a array of characters. Also, the pointer is useless as nothing is
>> being assigned to it afterward, yet its a full blown variable.
> Lets consider statement const char* sql_select = "SELECT 1, 'a'";
> "SELECT 1, 'a'" is a string literal. In accordance with C++ language
> standard (ISO/IEC 14882) an ordinary string literal has type “array
> of n const char” and static storage duration, where n is the size of
> the string as defined below, and is initialized with the given
> characters. (clause 2.13.4) sql_select is just name for this string
It's not just a name, it's a pointer.
> literal. I can make this variable declaration more strong and declare
> sql_select as
> const char* const sql_select = "SELECT 1, 'a'"; In any case
> sql_select is just label name for this string literal value.
No. The array case is the one that is just a "label".
> On the other hand If we declare sql_select as const char sql_select
> = "SELECT 1, 'a'"; we have array with name sql_select and this array
> filled by byte values from array corresponding to string literal
> value "SELECT 1, 'a'".
> I think this is not best approach.
Whatever, this is not a important.