Thread: I am unable to compile my very first Win32 code. Please help me out.

  1. #1
    Registered User
    Join Date
    Dec 2011
    Location
    India
    Posts
    2

    Unhappy I am unable to compile my very first Win32 code. Please help me out.

    I am using Visual C++ 2010 to compile the code given in this link:

    Code:
    http://www.cprogramming.com/tutorial/opengl_first_windows_app.html
    I used precompiled Win32 Project and I am still getting some errors:
    Code:
    1>c:\users\anoop\documents\visual studio 2010\projects\ui\ui\ui.cpp(33): error C2664: 'TextOutW' : cannot convert parameter 4 from 'char [14]' to 'LPCWSTR' 
    
    1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 
    
    1>c:\users\anoop\documents\visual studio 2010\projects\ui\ui\ui.cpp(63): error C2440: '=' : cannot convert from 'const char [8]' to 'LPCWSTR' 
    
    1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 
    
    1>c:\users\anoop\documents\visual studio 2010\projects\ui\ui\ui.cpp(82): error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [8]' to 'LPCWSTR' 
    
    1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    Please, help me.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    From the menu: Project -> Properties
    Select: Configurations: -> All Configurations
    Select: Configuration Properties -> General
    Select: Character Set -> Use Multi-Byte Character Set

    gg

  3. #3
    Registered User
    Join Date
    Dec 2011
    Location
    India
    Posts
    2

    Red face thanks

    thank you Codeplug for giving me solution to my problem.

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    319
    it would be handy if the compiler displayed that to you tho

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    It also might be nice if the tutorials used the character set independent macros, then it would compile with either setting.

    Then again, if everything always worked, you would never learn anything.
    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.

  6. #6
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    I highly discourage the use of TCHAR's, but every Win32 API user has to learn about them eventually.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 12-05-2011, 05:07 PM
  2. libusb: unable to compile
    By nndhawan in forum C Programming
    Replies: 1
    Last Post: 02-17-2011, 10:56 PM
  3. Replies: 7
    Last Post: 03-19-2010, 12:16 AM
  4. Dev-c++ + own .h files = unable to compile
    By wixz64 in forum C Programming
    Replies: 5
    Last Post: 05-29-2008, 03:35 PM
  5. Win32 API - unable to SetCapture properly
    By y_cant_i_C in forum Windows Programming
    Replies: 1
    Last Post: 10-15-2006, 02:07 AM

Tags for this Thread