Anderson
Anderson

Reputation: 3247

'BYTE' does not name a type || 'BOOL' has not been declared

When I run "g++" to make JNI I got "does not name a type" error.

g++ -shared -o finger.dll FingerPrintJNI.c

The following is the error messages

In file included from FingerPrintJNI.c:4:0:

IMM64.h:21:2: error: 'BYTE' does not name a type
BYTE Data[MAX_FEATUREVECT_LEN];
^~~~

IMM64.h:26:2: error: 'BYTE' does not name a type
BYTE Data[MAX_INDEXINFO_LEN];
^~~~

IMM64.h:31:2: error: 'BYTE' does not name a type
BYTE Data[MAX_INDEXINFO_LEN_1];
^~~~

IMM64.h:44:2: error: 'BYTE' does not name a type
BYTE kind;
^~~~

IMM64.h:55:2: error: 'BYTE' does not name a type
BYTE kind;
^~~~

IMM64.h:73:2: error: 'BOOL' has not been declared
BOOL *bResult, unsigned int *uiMatchScore, unsigned int *uiHit, Pair_t *hCPairs = NULL);

The header file looks something like this. ( I cannot share the whole code due to security reason)

XXX_API char * __stdcall XXXXDCI_GetVer();

Here are questions.

  1. "BYTE" has been declared as uppercase. does it have something to do with Visual Studio?

  2. the header file has "__stdcall". does it mean the header file is C++ ?

  3. I need to make JNI with the header file above. what do I have to do? Can I do it via g++ compiler? or gcc compiler? without Visual Studio?

Upvotes: 1

Views: 7181

Answers (2)

MBI
MBI

Reputation: 593

I had very similar error message (but on linux). I decided to solve it by following recommendation in google c++ style guide - to prefer types like int8_t, uint8_t, int16_t, int64_t etc., which are defined in <cstdint>. So for BYTE, which is short name for unsigned char I used uint8_t. This solution is applicable on linux and windows also.

Upvotes: 1

a3f
a3f

Reputation: 8657

  1. BYTE and BOOL are #defined in windows.h as unsigned char and int respectively. Either #include the <windows.h>, possible after #define WINDOWS_LEAN_AND_MEAN or typedef them yourself.
  2. __stdcall is the standard calling convention used for WinAPI functions.
  3. Check out other answers on Stackoverflow regarding that. No need to replicate what has been detailed elsewhere here.

Upvotes: 2

Related Questions