Thread: VFW32 Function Call Error C2664

  1. #1

    VFW32 Function Call Error C2664

    Im trying to write code that reads AVI file information. I use vfw.h

    The code is something like this:


    void OpenAVI(LPCSTR szFile); //declaration in header

    OpenAVI("test.avi"); // Calls function with filename in main

    void OpenAVI(LPCSTR szFile) // Opens avi file

    AVIStreamOpenFromFile(&pavi, szFile, streamtypeVIDEO, 0, OF_READ, NULL) ; // barfs on 2nd param

    end code:

    Here is the compiling error:
    error C2664: 'AVIStreamOpenFromFileW' : cannot convert parameter 2 from 'const char *' to 'const unsigned short *'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

    When I dont use classes in the header, this code compiles fine without a function declaration, however, with a class in the header, I get this error. Thank you for any help.

  2. #2
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Why not just try to do the cast? If that doesnt work then its something else in your code and we cant figure it out from the little you posted. Of and next time besure to use the code tags b/c we really dont like reading thought code that is written as text.
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  3. #3
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001

    void OpenAVI(LPCTSTR szFile);
    This should work.

  4. #4
    Registered User
    Join Date
    Apr 2002
    Thank you both very much for your quick replies.

    Monster: Ive used that before, but it causes massive errors in some AVI DLL other than VFW. The segment of code works perfectly, until I add a class to the program. As soon as the class is there, the 2nd parameter barfs.

    xds4ls: Im quite stale at programming, so I have tried to look up what you mean by 'just try to do the cast'. Ive been stuck on this problem C2664 for a week now, and Ive done lots of research. I just dont understand how the code has no problems when its run in a program without classes, and wont work with classes.
    Sorry about not posting the code as its supposed to, but it wouldnt let me use the tags as unregistered.

    I thought that maybe I needed to call a vfw class in front of the function as below, but this doesnt help.

       vfw::AVIStreamOpenFromFile(&pavi, szFile, streamtypeVIDEO, 0, OF_READ, NULL) //tried using stdapi:: and vfwapi:: in place of vfw:: - no success.
    I also tried the following, where I didnt pass the text into a variable:

    void OpenAVI()
       LPCSTR szFile="test.avi"; // Also tried using LPCTSTR
       AVIStreamOpenFromFile(&pavi, szFile, streamtypeVIDEO, 0, OF_READ, NULL);
    This too gives an invalid 2nd parameter, BUT ONLY in a program where I have a class in the header file.

    Thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  2. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  3. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 07:26 PM
  4. Loading files with a function call
    By ulillillia in forum C Programming
    Replies: 6
    Last Post: 04-10-2007, 07:19 PM
  5. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM