[unixODBC-support] Unicode and Wide Char strings

Neha Avasthy neha.avasthy at gmail.com
Tue Oct 19 11:36:26 BST 2010


You mean alloca here right?? (As a parameter to the function call)  . I was
going through the man pages for alloca and this is what I see

BUGS
       The alloca function is machine and compiler dependent. On many
systems
       its implementation is buggy. Its use is discouraged.

       On many systems alloca cannot be used inside the list of arguments
of
       a  function  call,  because  the  stack space reserved by alloca
would
       appear on the stack in the middle of the space for the function
argu-
       ments.

Wondering if this is safe to use ??? Dont want to get stuck with undefined
behavior and non portable code again.

Thanks
-Neha



On Tue, Oct 19, 2010 at 3:58 PM, Nick Gorham <nick at lurcher.org> wrote:

> Neha Avasthy wrote:
>
>> Thanks Nick.
>>
>> The code that I have has numerous such assignments to TCHAR using the _T
>> macro
>>
>> #define _T(x) __T(x)
>> #define __T(x) L##x
>>
>> I want to try something that requires minimal changes in the source code
>> and that can be altered at the macro level only for ex.
>>
>> #define _T(x) __T(x)
>> #define __T(x) Copy_to_Unicode (x)
>>
>> But not sure how this function Copy_to_Unicode will look like . Is it
>> something like mbstowcs () calls.
>>
>
> Something like (probably full of bugs, just a first stab)
>
>
> #define _T(x) __T(x)
> #define __T(x) (__copy_to_unicode(alloc( strlen((x))*sizeof(TCHAR)),
> strlen((x)), (x)))
>
> TCHAR *__copy_to_unicode( TCHAR *dest, int dest_len, char *src )
> {
>   TCHAR *ptr = dest;
>
>   while( *src && dest_len > 0 ) {
>         *ptr++ = *src++;
>         dest_len --;
>   }
>   *ptr = 0;
>
>   return dest;
>
> }
>
> --
> Nick
> _______________________________________________
> unixODBC-support mailing list
> unixODBC-support at mailman.unixodbc.org
> http://mailman.unixodbc.org/mailman/listinfo/unixodbc-support
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.unixodbc.org/pipermail/unixodbc-support/attachments/20101019/e90284b0/attachment-0001.html>


More information about the unixODBC-support mailing list