CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2004
    Posts
    481

    struct - a simple question.

    Hi Gurus,

    I having a trouble with structure. I am building Printer Port using Windows 2000 DDK (Free Build Enviroment).

    When I build the code, it shows the following error:
    printTest.c(49) : error C2032: '<Unknown>' : function cannot be member of struct
    '_LINEBYTE'

    In printTest.c, I have the following structure
    ------------------------------------------------------------------------------------------------------
    ....
    ....
    ....
    typedef struct _LINEBYTE
    {
    int test;
    int myTestFunction();
    }LineByte;
    ....
    ....
    ....
    -------------------------------------------------------------------------------------------------------

    When I compile using Visual C++, it works fine. If I ignore (commented out) this structure, it compile in Visual C++ and Windows 2000 DDK - Free Build Enviroment.

    I am just wondering, is the original (old C) structure does not support function? I think I was right, but I just need to confirm it with the GURUs.

    Thanks in advance for any help.

    Sam

  2. #2
    Join Date
    Dec 2004
    Posts
    85

    Re: struct - a simple question.

    Functions can only be part of structs in C++, not C. Your file has a *.c extension so vc++ thinks it is a C Source File. Unless you have to program in C (in which case the function cannot be in a struct), then I would just rename the file to printTest.cpp

  3. #3
    Join Date
    Oct 2004
    Posts
    481

    Re: struct - a simple question.

    Aha... That makes a lot of sense now.

    Thanks, Ben...

  4. #4
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: struct - a simple question.

    Well...the following would have answered your question already...

  5. #5
    Join Date
    Oct 2004
    Posts
    481

    Re: struct - a simple question.

    Yes... you are right... Thanks Andreas...

    Cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured