Thread: compile error when make a wchar_t conversion

  1. #1
    Registered User
    Join Date
    May 2006

    compile error when make a wchar_t conversion

    Hello everyone,

    Here is the code, and if I change line from

    static wchar_t* p[1] = {PREFIX((wchar_t*)_TEXT("FOO"))};


    static wchar_t* p[1] = {PREFIX(_TEXT("FOO"))};

    then code will be ok. Why?

    #define UNICODE
    #define _UNICODE
    // include tchar.h
    #define PREFIX(x)	(wchar_t*)_TEXT("GOO_") x
    int main (int argc, char** argv)
    	static wchar_t* p[1] = {PREFIX((wchar_t*)_TEXT("FOO"))};
    	return 0;
    main.c(10) : error C2064: term does not evaluate to a function taking -22 arguments
    main.c(10) : error C2143: syntax error : missing ')' before 'type'
    main.c(10) : error C2059: syntax error : ')'

    thanks in advance,

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    Why do you think it makes a difference? What happens in the macro?

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Why do you feel the need to cast everything if you're using the _TEXT macros?

    Perhaps if you also used the types declared in tchar.h in place of the rather too specific wchar_t you are using, then it would all work seamlessly.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie Again
    By christianne in forum C Programming
    Replies: 14
    Last Post: 04-06-2006, 12:39 AM
  2. Win32 Common Controls in C++, how do i make and use them?
    By C+noob in forum Windows Programming
    Replies: 6
    Last Post: 01-09-2006, 11:53 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. "Cannot make pipe"
    By crepincdotcom in forum C Programming
    Replies: 5
    Last Post: 08-16-2004, 12:43 PM
  5. Compile but cant print out answers
    By romeoz in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 11:29 AM