×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    11

    Unhappy In GCCE, -fshort-wchar compile option is not working.

    In GCCE, -fshort-wchar compile option is not working.

    I'm using Carbide.c++ 1.3 Express Edition.
    SDK is S60 3rd Edition FP1.

    I want to declare UTF-16(that is, 2-byte) string literal.
    I know there is _LIT(). But I'm carring a source code that is written in C, and that source code should be minimally modified. I will replace system-dependent low-level code, but not want to modify (seemingly) system independent part.

    How can I apply -fshort-wchar option to the compiler?
    I added it to the .mmp file, and I saw it is applied to the compiler's command line. But compiler still complains about the type difference between wchar_t and unsigned short.

    Please help me... :(

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: In GCCE, -fshort-wchar compile option is not working.

    Hi zeodtr,

    All header files related to C are present in \Symbian\9.1\S60_3rd\Epoc32\include\libc, so include SYSTEMINCLUDE \Epoc32\include\libc in your .mmp file. And then clean n rebuild ur project.

    savaj..:)

  3. #3
    Registered User
    Join Date
    Aug 2008
    Posts
    11

    Re: In GCCE, -fshort-wchar compile option is not working.

    Thank you savaj, but it was included already. And I cleaned the project many times.

    Quote Originally Posted by savaj View Post
    Hi zeodtr,

    All header files related to C are present in \Symbian\9.1\S60_3rd\Epoc32\include\libc, so include SYSTEMINCLUDE \Epoc32\include\libc in your .mmp file. And then clean n rebuild ur project.

    savaj..:)

  4. #4
    Registered User
    Join Date
    Aug 2003
    Location
    Oulu, Finland
    Posts
    1,122

    Re: In GCCE, -fshort-wchar compile option is not working.

    wchar_t and unsigned short work interoperably for me, using all WINSCW, ARMV5, GCCE compilers. GCCE both with and without -fshort-wchar option.

    Can you please paste some code snippet that demonstrates the error you are getting?

    Lauri

  5. #5
    Registered User
    Join Date
    Aug 2008
    Posts
    11

    Re: In GCCE, -fshort-wchar compile option is not working.

    Thank you, Lauri.

    What I mean is wchar_t* and unsigned short*.
    That is,

    unsigned short *s = L"2134";

    or,

    const wchar_t *s = L"1234";
    TPtrC16 ps(s);

    in WINSCW, they work fine. But GCCE, do not. (And now I'm testing ARMV5, it also shows error message.)

    Again, I know _LIT() exists. Above are examples.

    Quote Originally Posted by laa-laa View Post
    wchar_t and unsigned short work interoperably for me, using all WINSCW, ARMV5, GCCE compilers. GCCE both with and without -fshort-wchar option.

    Can you please paste some code snippet that demonstrates the error you are getting?

    Lauri

  6. #6
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: In GCCE, -fshort-wchar compile option is not working.

    Hi ,

    Type cast your const wchar_t* with (TText16*).

    const wchar_t *s = L"1234";
    TPtrC16 ps((TText16*)s);

    savaj..

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: In GCCE, -fshort-wchar compile option is not working.

    In fact you have not shown that error message.

  8. #8
    Registered User
    Join Date
    Aug 2008
    Posts
    11

    Re: In GCCE, -fshort-wchar compile option is not working.

    That can pass compilation.
    But since GCCE's wchar_t width is 4-bytes while the Symbian environment wants it to be 2-bytes, binary layout will be invalid.

    for example,

    on GCCE, L"123" will be compiled to binary form like this: { '1', 0, 0, 0, '2', 0, 0, 0, '3', 0, 0, 0, 0, 0, 0, 0 } (little endian)
    while Symbian wants it to be { '1', 0, '2', 0, '3', 0, 0, 0 }.

    It will not work...

    Quote Originally Posted by savaj View Post
    Hi ,

    Type cast your const wchar_t* with (TText16*).

    const wchar_t *s = L"1234";
    TPtrC16 ps((TText16*)s);

    savaj..

  9. #9
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: In GCCE, -fshort-wchar compile option is not working.

    Hi,

    what is the error message u got??

    const wchar_t *s = L"1234";
    TPtrC16 ps((TText16*)s);

    is working fine for me on emulator and device.

    savaj.

  10. #10
    Registered User
    Join Date
    Aug 2008
    Posts
    11

    Re: In GCCE, -fshort-wchar compile option is not working.

    I am terribly sorry.
    It was my mistake.

    The problem was that in GCC and ARMCC in C++ mode, wchar_t* is not compatible with any of integer-like pointers, that is, unsigned char*, unsigned short*, unsigned int*.
    I discovered it yesterday and changed the code accordingly (apply casting) for ARMCC with successful result, but left off the GCC, without changing outdated suspect - that is, GCC fails because of wchar_t*'s size.
    When I applied it to GCC, GCC also went nice.
    I was stupid. (although the situation was somewhat complex with having C legacy code in which the wchar_t is merely typedefed as unsigned short, etc.)
    It seems that in the Symbian (Carbide.c++) development environment, GCC is set up to have 2-byte wchar_t* in the first place. The problem is wchar_t*'s uniqueness on compatibility.

    Thank you very much for taking time and enlightening me.

    Quote Originally Posted by savaj View Post
    Hi,

    what is the error message u got??

    const wchar_t *s = L"1234";
    TPtrC16 ps((TText16*)s);

    is working fine for me on emulator and device.

    savaj.
    Last edited by zeodtr; 2008-09-12 at 08:53.

Similar Threads

  1. How to change compile option in Carbide.c++_v1.2?
    By zhangwei_Nirvana in forum Symbian
    Replies: 5
    Last Post: 2008-01-15, 12:07
  2. GCCE compile with CodeWarrior - a link problem
    By HennaI in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 4
    Last Post: 2006-11-21, 22:33
  3. Replies: 2
    Last Post: 2006-11-02, 15:06
  4. Import MMP with different option to UREL ou UDEB
    By Altexia in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 0
    Last Post: 2005-11-30, 17:54
  5. Compile stops working FIX
    By kabir1 in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2004-05-14, 10:44

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×