std::wstring error - HP UX

This is a discussion on std::wstring error - HP UX ; Hello, I am facing a problem with std::wstring. As given in the sample below, i am unable to print the string value. It just prints "L" (without double quotes) on the stdout. //sample.cpp #include #include #define PRINT(VALUE)\ { \ std::cout ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: std::wstring error

  1. std::wstring error

    Hello,

    I am facing a problem with std::wstring. As given in the sample below,
    i am unable to print the string value. It just prints "L" (without
    double quotes) on the stdout.

    //sample.cpp
    #include
    #include

    #define PRINT(VALUE)\
    { \
    std::cout << #VALUE << std::endl; \
    }

    int main()
    {
    PRINT(L"abcdegfdddstr");
    return 1;
    }

    I compile using aCC -AA sample.cpp

    Am I doing something wrong ?

    Any help is appreciated.

    Thanks and Regards,

    Zuber


  2. Re: std::wstring error

    Zuber wrote:
    : I am facing a problem with std::wstring. As given in the sample below,
    : I am unable to print the string value. It just prints "L" (without
    : double quotes) on the stdout.
    : #include
    : #include

    I see no wstring here. Just an array of wchar_t. You can leave out .

    : #define PRINT(VALUE) { std::cout << #VALUE << std::endl; }

    This macro is broken. Do you really want to use stringize (#) on something
    that is already a string. Remove the "#".
    If you use +legacy_cpp or aCC6, you would print out: L"abcdegfdddstr"
    This does appear to be a bug in aCC3. Stringizing a string seems well
    defined 16.3.2(2).

    : int main() {
    : PRINT(L"abcdegfdddstr");
    : }
    : I compile using aCC -AA sample.cpp
    : Am I doing something wrong?
    : Zuber

    You can't print wide char strings to cout, you must use wcout:
    std::wcout << L"abcdegfdddstr\n";

    If you have other aC++ questions, you may want to subscribe to the
    CXX-dev mailing list:
    http://h21007.www2.hp.com/dspp/comm/...,1273,,00.html

  3. Re: std::wstring error

    Thanks for the help, but i have tried to print it with wcout too but it
    does not make a difference.

    If the string is printed as

    wcout << L"abcdefg";

    it prints properly but if i try it using the program as given in my
    first mail it doesnt.

    Any ideas ??

    Zuber

    Dennis Handly wrote:

    > Zuber wrote:
    > : I am facing a problem with std::wstring. As given in the sample below,
    > : I am unable to print the string value. It just prints "L" (without
    > : double quotes) on the stdout.
    > : #include
    > : #include
    >
    > I see no wstring here. Just an array of wchar_t. You can leave out .
    >
    > : #define PRINT(VALUE) { std::cout << #VALUE << std::endl; }
    >
    > This macro is broken. Do you really want to use stringize (#) on something
    > that is already a string. Remove the "#".
    > If you use +legacy_cpp or aCC6, you would print out: L"abcdegfdddstr"
    > This does appear to be a bug in aCC3. Stringizing a string seems well
    > defined 16.3.2(2).
    >
    > : int main() {
    > : PRINT(L"abcdegfdddstr");
    > : }
    > : I compile using aCC -AA sample.cpp
    > : Am I doing something wrong?
    > : Zuber
    >
    > You can't print wide char strings to cout, you must use wcout:
    > std::wcout << L"abcdegfdddstr\n";
    >
    > If you have other aC++ questions, you may want to subscribe to the
    > CXX-dev mailing list:
    > http://h21007.www2.hp.com/dspp/comm/...,1273,,00.html



  4. Re: std::wstring error

    Zuber wrote:
    : If the string is printed as wcout << L"abcdefg";

    This is the only way to print wide string lits. Or assign them to wchar_t*.

    : but if i try it using the program as given in my first mail it doesnt.
    : Any ideas??
    : Zuber

    I told you. The compiler is broken. The workaround is to use +legacy_cpp.
    You will have to contact the Response Center to report the problem.

    I also asked why you want to do that in the first place??
    Since the # operator doesn't make a wchar_t array.

    : Dennis Handly wrote:
    : > : #define PRINT(VALUE) { std::cout << #VALUE << std::endl; }
    : >
    : > This macro is broken. Do you really want to use stringize (#) on something
    : > that is already a string. Remove the "#".
    : > If you use +legacy_cpp or aCC6, you would print out: L"abcdegfdddstr"
    : > This does appear to be a bug in aCC3. Stringizing a string seems well
    : > defined 16.3.2(2).

+ Reply to Thread