PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Problem compiling GAPI with legacy Win32 'C' DLL driver code

I am working on some legacy code written in Win32 'C' that implements a Windows CE driver. The driver is in the form of a DLL.

The driver needs to put animated graphics up on the screen. I am currently using the standard WinGDI functions (BitBlt, etc ...) but the response is too slow.

It looks like the direct access to video memory supplied by GAPI would improve the response.

When I add just the header "gx.h" to the source code I get compile errors.

gx.h(56) : error C2061: syntax error : identifier 'GXGetDisplayProperties'

gx.h(57) : error C2061: syntax error : identifier 'GXGetDefaultKeys'



The lines of code in gx.h are declarations for structures that are to be exported.


GXDLL_API GXDisplayProperties GXGetDisplayProperties();
GXDLL_API GXKeyList GXGetDefaultKeys(int iOptions);


where :


#ifdef GXDLL_EXPORTS
#define GXDLL_API __declspec(dllexport)
#else
#define GXDLL_API __declspec(dllimport)
#endif

and

the definition for the structures are:

struct GXDisplayProperties {
DWORD cxWidth;
DWORD cyHeight; // notice lack of 'th' in the word height.
long cbxPitch; // number of bytes to move right one x pixel - can be negative.
long cbyPitch; // number of bytes to move down one y pixel - can be negative.
long cBPP; // # of bits in each pixel
DWORD ffFormat; // format flags.
};

struct GXKeyList {
short vkUp; // key for up
POINT ptUp; // x,y position of key/button. Not on screen but in screen coordinates.
short vkDown;
POINT ptDown;
short vkLeft;
POINT ptLeft;
short vkRight;
POINT ptRight;
short vkA;
POINT ptA;
short vkB;
POINT ptB;
short vkC;
POINT ptC;
short vkStart;
POINT ptStart;
};




I don't have this problem if I compile the GAPI C++ sample code.


I can make the errors go away if I change the declarations to:


GXDLL_API struct GXDisplayProperties GXGetDisplayProperties();
GXDLL_API struct GXKeyList GXGetDefaultKeys(int iOptions);


When I try to link to the "gx.lib" though the linker can not find functions associated with the GX.LIB that were added to the source code.

I suspect that it is because GX.LIB is expecting a C++ calling convention that supports mangled function and variable names. As a result the 'C' linker does not know how to resolve the external functions in the GX.LIB.

I am compiling for an ARM processor. I have checked to see that I have the correct library specified and I have specified the path in the include for gx.h.


Has anyone had experience trying to use the GAPI library with a Win32 C program? A work around would be great.

Alternatively, can someone suggest a third party graphics library. It looks like PocketHAL, PocketFROG and EasyCE as C++ based libraries. Fastgraph seems to be one of the few that support C.
Th eproblem is that you are coding in 'C' and GAPI uses C++ linkage.

To get around the systax error you mention:

Change:

Code:

GXDLL_API GXDisplayProperties GXGetDisplayProperties();
GXDLL_API GXKeyList GXGetDefaultKeys(int iOptions);


With:

Code:

GXDLL_API struct GXDisplayProperties GXGetDisplayProperties();
GXDLL_API struct GXKeyList GXGetDefaultKeys(int iOptions);


However, when you come to link your program, you will get link errors. (You are trying to link a C++ lib into C.

Use extern 'C' to get around this.
HLEW · 27 May 2005, 09:35 UTC — Problem compiling GAPI with legacy Win32 'C' DLL driver code
Thanks,

That explains my problem. That is a big help.