Results 1 to 8 of 8

Thread: Qt has wchar_t as non-native?

  1. #1
    Join Date
    Aug 2010
    Posts
    65
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Qt has wchar_t as non-native?

    In qmake's .conf file for Visual 2008, it has the following line:

    Qt Code:
    1. QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t-
    To copy to clipboard, switch view to plain text mode 

    I've had a few problems using another library and I've been informed this is due to Qt compiling with "treat wchar_t as a built-in type" as false, as evidenced by the code above.

    Is there any particular reason for this? I've also been told to alter this .conf file, recompile Qt and it should still work just fine.

  2. #2
    Join Date
    Aug 2010
    Posts
    65
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt has wchar_t as non-native?

    Could anyone please answer this?

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt has wchar_t as non-native?

    /Zc:wchar_t turns on "wchar_t Is Native Type" according to the docs: http://msdn.microsoft.com/en-us/libr...8VS.71%29.aspx
    I cannot see any documentation of the appended hyphen, which I assume negates the option.

    Since this affects compilation, and not dynamic linking, I can only assume you incorporated the code of the other library into your own.

    Options:
    • Build the other library separately (using its own Makefiles etc.) and dynamically link to it.
    • Build the other library separately and statically link to it.
    • #include <wchar.h> in the library source files to define wchar_t (See MS doc above)
    • quarantine the other library code in a separate directory within your source and
      change QMAKE_CFLAGS in the PRO file that builds that portion.

  4. #4
    Join Date
    Aug 2010
    Posts
    65
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt has wchar_t as non-native?

    Thing is, I've been using this other library (SFML) for a while now and it works quite fine. It was only when I tried to build a program as a qmake makefile that it gave an error (as opposed to a standard Visual Studio build... whatever one's supposed to call that...). And all the errors were due to "function overloads" involving wchar.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt has wchar_t as non-native?

    I assume the error message building your program stems from the include files out of SFML. If you:
    Qt Code:
    1. #include <wchar.h>
    2. #include <SFML/...>
    To copy to clipboard, switch view to plain text mode 
    in your source files does that straighten it out?

  6. #6
    Join Date
    Aug 2010
    Posts
    65
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt has wchar_t as non-native?

    Well, by the time I'd seen your guys' responses, I'd already had Qt recompiling without that "-Zc:wchar_t-" flag. While simply adding #include <wchar.h> would probably have been far easier (not to mention Qt-compliant), everything seems to be working perfectly well. Qt isn't spitting out any warnings or errors, qmake is building everything just fine, SIGNALS and SLOTS are working as per usual, and SFML and is most pleased.

    So, for the record, while simply doing the #include should work (I didn't try it myself, but it makes all the sense in the world), recompiling Qt without the flag seems to work as well.

    Though I am just a newbie and for all I know qmake is crying in desperation.

  7. #7
    Join Date
    Jul 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt has wchar_t as non-native?

    I had the same problem and foudn that just including wchar.h didn't work because all libraries used are compiled with "-Zc:wchar_t-", so you get linker errors. Compiling Qt with the adusted .conf file is the only solution here. There is already an issue submitted on this. See http://bugreports.qt.nokia.com/browse/QTBUG-9617 for more details

  8. #8
    Join Date
    Nov 2010
    Posts
    97
    Thanks
    6
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt has wchar_t as non-native?

    Quote Originally Posted by Peacs View Post
    I had the same problem and foudn that just including wchar.h didn't work because all libraries used are compiled with "-Zc:wchar_t-", so you get linker errors. Compiling Qt with the adusted .conf file is the only solution here. There is already an issue submitted on this. See http://bugreports.qt.nokia.com/browse/QTBUG-9617 for more details
    Anyone know why in this one: http://bugreports.qt.nokia.com/brows...nel#issue-tabs they say that building Qt this way won't be supported? The question's been sitting there for a year and nobody's ever answered it! I've been scared to apply this fix to our situation because of that statement but it's really becoming a true PITA.

    And WTF do BIC and SIC mean??

Similar Threads

  1. Intrinsic / External wchar_t use in Qt
    By rcj in forum Qt Programming
    Replies: 0
    Last Post: 14th March 2010, 06:21
  2. QString -> wchar_t*
    By elizabeth.h1 in forum Qt Programming
    Replies: 0
    Last Post: 26th October 2009, 09:34
  3. QString to wchar_t
    By rajveer in forum Qt Programming
    Replies: 1
    Last Post: 4th September 2008, 06:11
  4. How to convert wchar_t* into char*??
    By shailesh in forum Qt Programming
    Replies: 3
    Last Post: 22nd June 2006, 12:39
  5. QString and wchar_t?
    By jamos in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2006, 18:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.