I have a structure for the mouse I plan to use. This is declared in my Header file
Input.h
struct MOUSEINFO
{
// Contains Information about the Mouse
int Mx; //Mouse Location (X-coord)
int My; //Mouse Location (Y-coord)
short Mright; //Mouse Button (Right State) | 1 = Down | 0 = Up
short Mleft; //Mouse Button (Left State) | 1 = Down | 0 = Up
};
Underneath this I have declared:
extern short Key; // Key monitor
extern MOUSEINFO Mouse; //Mouse Monitor
When I try and complie my program, I get the following error:
Quote
~/../../Input.H(17): error #2001: Syntax error: expected ';' but found 'Mouse'.
I have no idea how to fix this error. I reckon I am being very silly, as I am very new to C (as I used to work with C#) and missing a semi-colon or some include somewhere, but I can't seem to find it myself. If anyone can help, that'd be great!
Ops -Silly me , i was trying to use the struct as a variable type.
However I have fixed this error, but am now getting a
POLINK ErrorQuote
POLINK: error: Unresolved external symbol '__penter'.
POLINK: error: Unresolved external symbol '_Mouse'.
I have no idea what "_penter" is or when it's found.
I'm assuming "_Mouse" is my variable Mouse structure (now fixed :)!):
struct MOUSEINFO
{
int Mx;
int My;
short Mright;
short Mleft;
} extern Mouse;
Any idea how I could fix these errors?
(Would I copy of my complier and Linker settings aid any?)
Thanks
Quote from: eweeee on January 16, 2013, 02:51:44 PM
Ops -Silly me , i was trying to use the struct as a variable type.
However I have fixed this error, but am now getting a POLINK Error
Quote
POLINK: error: Unresolved external symbol '__penter'.
POLINK: error: Unresolved external symbol '_Mouse'.
Go into the main menu Project -> Project Settings -> Compiler ... turn off the "Emit hook function calls" option, and any other option you don't actually need to make your project work. Generally the only checked options you need are the Microsoft Extensions and Pelles C extensions...
:D General rule ... if you don't know what it is, don't turn it on.
Quote
struct MOUSEINFO
{
int Mx;
int My;
short Mright;
short Mleft;
} extern Mouse;
Any idea how I could fix these errors?
(Would I copy of my complier and Linker settings aid any?)
Ok the most compliant way to declare a struct in Windows code is like this...
// in your header file...
// structure declaration
typedef struct tMOUSEINFO
{
INT mX;
INT mY;
BOOL mRight;
BOOL mLeft;
} MOUSEINFO, *PMOUSEINFO;
extern MOUSEINFO MyMouseInfo;
// in the file where data is written to the struct
MOUSEINFO MyMouseInfo;
This will create a MOUSEINFO and a PMOUSINFO type ... the first is the struct and the second is a pointer to the struct. You would use them just like regular Windows structs.
Firstly - thank you for that. I shall use this format now.
However:
Quote
BOOL mRight;
BOOL mLeft;
I thought bool(boolean) variables were a feature which C doesn't have? I could be wrong. I did notive thet appeared brown and not blue in Pelles C.
I checked my complier and all things wre off but the MS and Pelles checks. It was the pointer (ugh) that fixed my problem.
Quote from: eweeee on January 16, 2013, 04:49:12 PM
Firstly - thank you for that. I shall use this format now.
However:
Quote
BOOL mRight;
BOOL mLeft;
I thought bool(boolean) variables were a feature which C doesn't have? I could be wrong.
Welcome to ANSI C[99|11]! ;)
QuoteI did notive thet appeared brown and not blue in Pelles C.
That's because it's a pre-processor directive...
Ralf
Thanks for all the help :)
Quote from: eweeee on January 16, 2013, 04:49:12 PM
Firstly - thank you for that. I shall use this format now.
However:
Quote
BOOL mRight;
BOOL mLeft;
I thought bool(boolean) variables were a feature which C doesn't have? I could be wrong. I did notive thet appeared brown and not blue in Pelles C.
I checked my complier and all things wre off but the MS and Pelles checks. It was the pointer (ugh) that fixed my problem.
Actually those are typedefed in Windows API .... Simply #include <windows.h> in your source code.
If you don't have the msdn documentation (Windows SDK) on your system you should get it... there's a ton and a half of useful information.
There's an AddIn you can install that will let you search Windows SDK help files with F1 on your keyboard... you can dlownload it ....
HERE (http://forum.pellesc.de/index.php?topic=5042.msg19173#msg19173) ... Instructions for AddIns are ...
HERE (http://forum.pellesc.de/index.php?topic=4692.msg18087#msg18087)
Quote from: CommonTater on January 16, 2013, 07:14:32 PM
Actually those are typedefed in Windows API .... Simply #include <windows.h> in your source code.
Actually, bool/_Bool and the associated header file stdbool.h is standard C since ANSI C99 (http://en.wikipedia.org/wiki/Stdbool.h#Boolean_type)... ;-)
Ralf
PS: The official standards document can be found at http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
Quote from: Bitbeisser on January 16, 2013, 09:12:47 PM
Actually, bool/_Bool and the associated header file stdbool.h is standard C since ANSI C99 (http://en.wikipedia.org/wiki/Stdbool.h#Boolean_type)... ;-)
Oh for crying out loud Ralf ... If I say "you win" will you stop this neverending tirade of contradiction?
In case you forgot C is case sensitive... bool and _Bool are not BOOL. To be certain of Windows compliance you use the definition from the windows headers... typedef int BOOL;
BOOL has been in the windows headers since Win95 (at least). In fact, here's a copy of WINDEF.H, which is included by WINDOWS.H, right out of the Pelles C Include directory, you can look at...
#ifndef _WINDEF_H
#define _WINDEF_H
#if __POCC__ >= 500
#pragma once
#endif
/* Windows Basic Type Definitions */
#ifndef NO_STRICT
#ifndef STRICT
#define STRICT 1
#endif
#endif /* NO_STRICT */
#ifdef __cplusplus
extern "C" {
#endif
#if __POCC__ >= 290
#pragma warn(push)
#pragma warn(disable:2027 2028) /* Missing prototype */
#endif
#ifndef WINVER
#define WINVER 0x0500
#endif
#ifndef BASETYPES
#define BASETYPES
typedef unsigned long ULONG;
typedef ULONG *PULONG;
typedef unsigned short USHORT;
typedef USHORT *PUSHORT;
typedef unsigned char UCHAR;
typedef UCHAR *PUCHAR;
typedef char *PSZ;
#endif /* BASETYPES */
#define MAX_PATH 260
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef IN
#define IN
#endif
#ifndef OUT
#define OUT
#endif
#ifndef OPTIONAL
#define OPTIONAL
#endif
#undef pascal
#define pascal __stdcall
#define cdecl
#ifndef CDECL
#define CDECL
#endif
#define far
#ifndef FAR
#define FAR
#endif
#define near
#ifndef NEAR
#define NEAR
#endif
#define CALLBACK __stdcall
#define WINAPI __stdcall
#define WINAPIV __cdecl
#define APIENTRY WINAPI
#define APIPRIVATE __stdcall
#define PASCAL __stdcall
#ifndef CONST
#define CONST const
#endif
typedef unsigned long DWORD;
typedef int BOOL;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef float FLOAT;
typedef FLOAT *PFLOAT;
typedef BOOL *PBOOL;
typedef BOOL *LPBOOL;
typedef BYTE *PBYTE;
typedef BYTE *LPBYTE;
typedef int INT;
typedef int *PINT;
typedef int *LPINT;
typedef unsigned int UINT;
typedef unsigned int *PUINT;
typedef WORD *PWORD;
typedef WORD *LPWORD;
typedef long *LPLONG;
typedef DWORD *PDWORD;
typedef DWORD *LPDWORD;
typedef void *LPVOID;
typedef CONST void *PCVOID;
typedef CONST void *LPCVOID;
#ifndef NT_INCLUDED
#include <winnt.h>
#endif /* NT_INCLUDED */
typedef UINT_PTR WPARAM;
typedef LONG_PTR LPARAM;
typedef LONG_PTR LRESULT;
#ifndef NOMINMAX
#ifndef max
#define max(a,b) (((a)>(b))?(a):(b))
#endif
#ifndef min
#define min(a,b) (((a)<(b))?(a):(b))
#endif
#endif /* NOMINMAX */
#define MAKEWORD(a, b) ((WORD)(((BYTE)((DWORD_PTR)(a)&0xFF))|((WORD)((BYTE)((DWORD_PTR)(b)&0xFF)))<<8))
#define MAKELONG(a, b) ((LONG)(((WORD)((DWORD_PTR)(a)&0xFFFF))|((DWORD)((WORD)((DWORD_PTR)(b)&0xFFFF)))<<16))
#define LOWORD(l) ((WORD)((DWORD_PTR)(l)&0xFFFF))
#define HIWORD(l) ((WORD)((DWORD_PTR)(l)>>16))
#define LOBYTE(w) ((BYTE)((DWORD_PTR)(w)&0xFF))
#define HIBYTE(w) ((BYTE)((DWORD_PTR)(w)>>8))
DECLARE_HANDLE(HWND);
DECLARE_HANDLE(HHOOK);
#ifdef WINABLE
DECLARE_HANDLE(HEVENT);
#endif
typedef WORD ATOM;
typedef HANDLE *SPHANDLE;
typedef HANDLE *LPHANDLE;
typedef HANDLE HGLOBAL;
typedef HANDLE HLOCAL;
typedef HANDLE GLOBALHANDLE;
typedef HANDLE LOCALHANDLE;
#ifdef _WIN64
typedef INT_PTR (WINAPI *FARPROC)();
typedef INT_PTR (WINAPI *NEARPROC)();
typedef INT_PTR (WINAPI *PROC)();
#else
typedef int (WINAPI *FARPROC)();
typedef int (WINAPI *NEARPROC)();
typedef int (WINAPI *PROC)();
#endif /* _WIN64 */
#ifdef STRICT
typedef void *HGDIOBJ;
#else
DECLARE_HANDLE(HGDIOBJ);
#endif
DECLARE_HANDLE(HKEY);
typedef HKEY *PHKEY;
DECLARE_HANDLE(HACCEL);
DECLARE_HANDLE(HBITMAP);
DECLARE_HANDLE(HBRUSH);
DECLARE_HANDLE(HCOLORSPACE);
DECLARE_HANDLE(HDC);
DECLARE_HANDLE(HGLRC);
DECLARE_HANDLE(HDESK);
DECLARE_HANDLE(HENHMETAFILE);
DECLARE_HANDLE(HFONT);
DECLARE_HANDLE(HICON);
DECLARE_HANDLE(HMENU);
DECLARE_HANDLE(HMETAFILE);
DECLARE_HANDLE(HINSTANCE);
typedef HINSTANCE HMODULE;
DECLARE_HANDLE(HPALETTE);
DECLARE_HANDLE(HPEN);
DECLARE_HANDLE(HRGN);
DECLARE_HANDLE(HRSRC);
DECLARE_HANDLE(HSTR);
DECLARE_HANDLE(HTASK);
DECLARE_HANDLE(HWINSTA);
DECLARE_HANDLE(HKL);
#if (WINVER >= 0x0500)
DECLARE_HANDLE(HMONITOR);
DECLARE_HANDLE(HWINEVENTHOOK);
#endif /* WINVER >= 0x0500 */
typedef int HFILE;
typedef HICON HCURSOR;
typedef DWORD COLORREF;
typedef DWORD *LPCOLORREF;
#define HFILE_ERROR ((HFILE)-1)
typedef struct tagRECT {
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT, *PRECT, *NPRECT, *LPRECT;
typedef const RECT *LPCRECT;
typedef struct _RECTL {
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECTL, *PRECTL, *LPRECTL;
typedef const RECTL *LPCRECTL;
typedef struct tagPOINT {
LONG x;
LONG y;
} POINT, *PPOINT, *NPPOINT, *LPPOINT;
typedef struct _POINTL {
LONG x;
LONG y;
} POINTL, *PPOINTL;
typedef struct tagSIZE {
LONG cx;
LONG cy;
} SIZE, *PSIZE, *LPSIZE;
typedef SIZE SIZEL;
typedef SIZE *PSIZEL, *LPSIZEL;
typedef struct tagPOINTS {
SHORT x;
SHORT y;
} POINTS, *PPOINTS, *LPPOINTS;
#define DM_UPDATE 1
#define DM_COPY 2
#define DM_PROMPT 4
#define DM_MODIFY 8
#define DM_IN_BUFFER DM_MODIFY
#define DM_IN_PROMPT DM_PROMPT
#define DM_OUT_BUFFER DM_COPY
#define DM_OUT_DEFAULT DM_UPDATE
#define DC_FIELDS 1
#define DC_PAPERS 2
#define DC_PAPERSIZE 3
#define DC_MINEXTENT 4
#define DC_MAXEXTENT 5
#define DC_BINS 6
#define DC_DUPLEX 7
#define DC_SIZE 8
#define DC_EXTRA 9
#define DC_VERSION 10
#define DC_DRIVER 11
#define DC_BINNAMES 12
#define DC_ENUMRESOLUTIONS 13
#define DC_FILEDEPENDENCIES 14
#define DC_TRUETYPE 15
#define DC_PAPERNAMES 16
#define DC_ORIENTATION 17
#define DC_COPIES 18
#if __POCC__ >= 290
#pragma warn(pop)
#endif
#ifdef __cplusplus
}
#endif
#endif /* _WINDEF_H */
Quote from: Bitbeisser on January 16, 2013, 06:35:45 PM
That's because it's a pre-processor directive...
In Windows, BOOL is a typedef.
Quote from: CommonTater on January 16, 2013, 11:11:24 PM
Quote from: Bitbeisser on January 16, 2013, 09:12:47 PM
Actually, bool/_Bool and the associated header file stdbool.h is standard C since ANSI C99 (http://en.wikipedia.org/wiki/Stdbool.h#Boolean_type)... ;-)
Oh for crying out loud Ralf ... If I say "you win" will you stop this neverending tirade of contradiction?
This has nothing to do with "never ending tirade of contradiction" but answering the question of the OP.
Since C99, C has by default a boolean type per language description and that was the OP's question
QuoteI thought bool(boolean) variables were a feature which C doesn't have?
Quote from: Bitbeisser on January 17, 2013, 05:48:27 AM
This has nothing to do with "never ending tirade of contradiction" but answering the question of the OP.
Ok... you win.