Click to See Complete Forum and Search --> : struct - a simple question.


ryu
December 13th, 2004, 05:28 PM
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

Ben_Phillips
December 13th, 2004, 05:33 PM
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

ryu
December 13th, 2004, 05:38 PM
Aha... That makes a lot of sense now.

Thanks, Ben...

Andreas Masur
December 14th, 2004, 03:36 AM
Well...the following would have answered your question already... :cool:
C2032 (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/C2032.asp)

ryu
December 28th, 2004, 06:37 PM
Yes... you are right... Thanks Andreas...

Cheers :)