Unexpected expression compiler error

My compiler (GCC) keeps expecting an expression where it shouldn't in 1 specific piece of my code:
1
2
3
4
5
int zxcNewWindow( HWND parent, TCHAR *text, zxWINDOW *kid,
  UINT style, int x, int y, int w, int h, int type )
// right here
{
  *kid = zxDefWINDOW;

The project contains only 2 files right now and the settings are just the default for an empty Code::Blocks 12.11 project. Both files are in UTF-8 format (tried in ASCII too), I just cannot see why this is not compiling correctly. I'll post the files in the next two posts.

Edit: For those of you who didn't get what the error was from the above here's the full log:
1
2
3
4
5
mingw32-gcc.exe -Wall  -g -DzxDEBUG     -c C:\Me\Prjs\cpp\zxGUI\main.c -o obj\main.o
C:\Me\Prjs\cpp\zxGUI\main.c: In function 'zxcNewWindow':
C:\Me\Prjs\cpp\zxGUI\main.c:39:10: error: expected expression before '{' token
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings (0 minutes, 0 seconds)
Last edited on
main.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <windows.h>

#ifndef main_h
#define main_h

typedef struct zxWINDOW_struct
{
  HWND     m_mswHwnd;
  WNDCLASS m_mswWc;
} zxWINDOW;
#define T( m_txt ) TEXT( m_txt )
LRESULT CALLBACK zx_mswWndProc(
  HWND   hWnd,
  UINT   message,
  WPARAM wParam,
  LPARAM lParam );
#define zxMswDefWNDCLASS {\
  .style         = 0u,\
  .lpfnWndProc   = zx_mswWndProc,\
  .cbClsExtra    = 0,\
  .cbWndExtra    = 0,\
  .hIcon         = NULL,\
  .hCursor       = NULL,\
  .hInstance     = NULL,\
  .hbrBackground = (HBRUSH)(COLOR_BACKGROUND),\
  .lpszMenuName  = NULL,\
  .lpszClassName = NULL }

#define zxDefWINDOW {\
  .m_mswHwnd = NULL,\
  .m_mswWc   = zxMswDefWNDCLASS }

static TCHAR* zxGuiTitle = T("zxGUI_msw");
static HINSTANCE zxMswThisI = NULL;

typedef enum zxWIN_TYPE_enum
{
  zxWIN_NULL = 0,
  zxWIN_FRAME,
  zxWIN_TEXTBOX,
  zxWIN_COUNT,
  zxWIN_DUMMY = 0xFFFFFFFF
} zxWinType;

int zxcNewWindow( HWND parent, TCHAR* text, zxWINDOW* kid,
  UINT style, int x, int y, int w, int h, int type );

#endif 
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "main.h"
int WINAPI WinMain( HINSTANCE hThisI, HINSTANCE hPrevI,
  PSTR lpCmdLine, int nCmdShow )
{
  MSG msg = {0};
  int err = 0;
  zxWINDOW win = {0}, kid = {0};
  zxMswThisI = hThisI;
  err = zxcNewWindow( NULL, zxGuiTitle, &win,
    WS_OVERLAPPEDWINDOW, 0, 0, 640, 480, zxWIN_FRAME );
  if ( err != 0 )
    return err;
  err = zxcNewWindow( win.m_mswHwnd, T("Textbox"), &kid,
    WS_CHILD, 1, 1, 100, 30, zxWIN_TEXTBOX );
  if ( err != 0 )
    PostQuitMessage( err );
  ShowWindow( win.m_mswHwnd, SW_SHOW );
  ShowWindow( kid.m_mswHwnd, SW_SHOW );
  while ( GetMessage( &msg, NULL, 0, 0 ) > 0 )
    DispatchMessage( &msg );
  return 0;
}

LRESULT CALLBACK zx_mswWndProc( HWND hWnd,
  UINT message, WPARAM wParam, LPARAM lParam )
{
  switch(message)
  {
  case WM_CLOSE:
    PostQuitMessage(0);
    break;
  default:
    return DefWindowProc( hWnd, message, wParam, lParam );
  }
  return 0;
}

int zxcNewWindow( HWND parent, TCHAR *text, zxWINDOW *kid,
  UINT style, int x, int y, int w, int h, int type )
{
  *kid = zxDefWINDOW;
  kid->m_mswWc.hInstance = zxMswThisI;
  switch ( type )
  {
  case zxWIN_FRAME:
    kid->m_mswWc.lpszClassName = T("MDICLIENT");
    break;
  case zxWIN_TEXTBOX:
    kid->m_mswWc.lpszClassName = T("EDIT");
    break;
  default:
    return 1;
  }
  if ( !RegisterClass( &kid->m_mswWc ) )
    return 1;
  kid->m_mswHwnd = CreateWindow(
  kid->m_mswWc.lpszClassName, text,
    style, x, y, w, h, parent, NULL, zxMswThisI, NULL );
  if ( !kid->m_mswHwnd )
    return 2;
  return 0;
}
Last edited on
closed account (Dy7SLyTq)
whats the error?
Explained in 1st post
closed account (Dy7SLyTq)
no its not. thats very vague what you said. i can think of three seperate errors that use the word expression. could you please post the whole error?
Can't get clearer than that.
Edit: Just in case you didn't check I have added the log.
Last edited on
closed account (Dy7SLyTq)
thank you thats perfect (and thanks for putting in the edit because i thought you were talking about your previous error info, which made me mad. so my bad). let me take a look now
It seems the compiler did not *kid = zxDefWINDOW;
I found this out after I took it out to make use of a few member variables I added so I could remove the x, y, w, h parameters from zxcNewWindow. Compiles perfectly now.
Last edited on
Topic archived. No new replies allowed.