![]() |
| | #1 |
| Math wizard Join Date: Dec 2006 Location: Minot, ND, USA
Posts: 516
| An error is driving me nuts! 1>.\Menus.c(245) : error C2143: syntax error : missing '{' before '*' I'm apparently going to have to post the entire code (cutting repetition out as noted) for the whole program (it's just a core Windows program so there's essentially nothing to it isn't much to it at all: In the root file: Code: // 3D modeling program.c : Defines the entry point for the application.
// Keep this file short - make a new file for each new aspect.
// common stuff
#define _CRT_SECURE_NO_DEPRECATE
#define degrees 0.017453292519943295769236907684886 // multiply by this to convert angles in degrees to radians
#include <windows.h> // these are all standard includes
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
HWND WindowHandle; // window handle
WNDCLASSEX WindowClass; // for a window class
MSG msg; // a message for windows
int ProgramRunning = 1; // the program is running by default
// string stuff
char TextString[2048]; // a string for text to use
// Debug-related things
char DebugDetails[512]; // string for indicating errors
double DebugTest[25]; // for displaying values
int DebugPointerTest[5];
// general variables
char WarningString[512]; // used to display warnings and errors
#include "Menus.c" // this problematic file is at the end
// Putting an HMENU declaration right here causes no error to occur....
// Windows Procedure Event Handler
LRESULT CALLBACK WndProc(HWND WindowHandle, UINT message, WPARAM wParam, LPARAM lParam)
{
// Switch message, condition that is met will execute
switch(message)
{
// Window is being created
case WM_CREATE:
return 0;
break;
// Window is closing
case WM_CLOSE:
PostQuitMessage(0);
ProgramRunning = 0; // to terminate the loop
return 0;
break;
default:
break;
}
return (DefWindowProc(WindowHandle, message, wParam, lParam));
}
// Main windows function - the point from which the program starts from
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// Fill out the window class structure
WindowClass.cbSize = sizeof(WNDCLASSEX);
WindowClass.style = CS_HREDRAW | CS_VREDRAW;
WindowClass.lpfnWndProc = WndProc;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hInstance = hInstance;
WindowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WindowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WindowClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
WindowClass.lpszMenuName = NULL;
WindowClass.lpszClassName = "MyClass";
WindowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
// Register the window class
if (!RegisterClassEx(&WindowClass))
{
return 1;
}
SetUpMenus(); // sets up the menus, assigning handles
// Class registered, so now create window
WindowHandle = CreateWindow("MyClass", // class name
"The 3D scene and level creator 1.0 (development version)", // app name
WS_OVERLAPPEDWINDOW | // window style
WS_VISIBLE |
WS_MAXIMIZE,
0, 0, // x/y coords
768, 512, // width,height
NULL, // handle to parent
MenuMainHandle, // handle to menu
hInstance, // application instance
NULL); // no extra parameter's
// Check if window creation failed
if (!WindowHandle)
{
return 0;
}
DrawMenuBar(WindowHandle); // this has no problems
while (ProgramRunning == 1) // this is the main loop
{
PeekMessage(&msg, WindowHandle, 0, 0, PM_REMOVE);
if (msg.message == WM_QUIT) // check for a quit message
{
ProgramRunning = 0; // if found, quit app
break;
}
else
{
// Finally, translate and dispatch any messages into event queue so other programs can run
Sleep(1); // wait some milliseconds
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
// main loop has ended, program ended - free up handles and other resources to prevent memory leaks
UnregisterClass("MyClass", hInstance); // frees the resources/memory
DestroyWindow(WindowHandle);
QuitMenus(); // for the menus
return 0; // terminate the program
}
Code: // Menus.c: This file involves the functions and controls from the menus.
// Call the "ProcessMenuCommand" function in the WS_COMMAND Windows message.
// Call the "QuitMenus" function upon closing to free up the resources.
// defines
/*
The ID for each menu item should follow a consistent pattern. For this, bit masking would be useful.
0xE000 - menu bar - the headers that are always visible (maximum: 8)
0x1F00 - menu options - these are visible when the always-visible ones are clicked on (maximum: 32)
0x00E0 - submenus (maximum: 8)
0x0010 - flag for checked elements (0 if unchecked, 1 if checked)
0x0008 - flag for grayed elements (0 if normal, 1 if grayed; disabled is never used)
0x0007 - other variations (strings, other states, etc.)
*/
#define FileRoot 0x0000 // used for opening and saving files
#define FileNew 0x0100 // creates a new, blank file
#define FileOpen 0x0200 // opens an existing file
#define FileSave 0x0300 // saves the current file
#define FileSaveAs 0x0400 // saves the current file under a new name
#define EditRoot 0x2000 // Used for general manipulation of the scene
// nothing but about 130 defines are here in the same format as above
// structures
// Menu handles
HMENU MenuMainHandle; // error - there's a problem with this identifier and all those below
HMENU MenuFileHandle;
HMENU MenuEditHandle;
HMENU MenuViewHandle;
HMENU MenuObjectHandle;
HMENU MenuObjectNew2DShapeHandle;
HMENU MenuObjectNew3DShapeHandle;
HMENU MenuToolsHandle;
HMENU MenuOptionsHandle;
HMENU MenuOptions2DViewsHandle;
HMENU MenuOptions3DViewHandle;
HMENU MenuOptionsVertexMarkersHandle;
HMENU MenuOptionsShowHideHandle;
HMENU MenuOptionsMeasurementHandle;
HMENU MenuHelpHandle;
BITMAPINFOHEADER TestBMPInfo; // Test case but this gets the same error as the above and below
MENUITEMINFO MenuFileInfo; // this also errors in the same way
MENUITEMINFO MenuFileNewInfo;
MENUITEMINFO MenuFileOpenInfo;
MENUITEMINFO MenuFileSaveInfo;
MENUITEMINFO MenuFileSaveAsInfo;
MENUITEMINFO MenuEditInfo;
MENUITEMINFO MenuEditUndoInfo;
// list to be completed
// string stuff
/* these things are important to keep for debugging
sprintf(DebugDetails, "The resulting value is %d.", DebugTest);
MessageBox(WindowHandle, DebugDetails, "Debug Results", MB_OK);
*/
// general variables
// other things
FILE *FileHandle; // handle for reading/writing files
// the line above has "missing { before *" as the error
// functions
/*
Function: SetUpMenus
What it does: Sets up menus, preparing them for use.
Parameters: None.
The routine: Stage 1 - repeatedly call "CreateMenu" to assign handles for the menus.
Return value: Nothing - if it fails, use MessageBox to mention what problem was encountered.
Remarks: There's a lot of repetion expected so form templates to speed the process up.
To do: Write this function. Use the defines at the top to make it easier to identify the menu command.
*/
void SetUpMenus()
{
MenuMainHandle = CreateMenu(); // assign the handle to the menus and submenus
// the above has "undeclared identifier" as the error - the below has the same
// the Windows function, CreateMenu, is also undeclared which is very suspicious
MenuFileHandle = CreateMenu();
MenuEditHandle = CreateMenu();
MenuViewHandle = CreateMenu();
MenuObjectHandle = CreateMenu();
MenuObjectNew2DShapeHandle = CreateMenu();
MenuObjectNew3DShapeHandle = CreateMenu();
MenuToolsHandle = CreateMenu();
MenuOptionsHandle = CreateMenu();
MenuOptions2DViewsHandle = CreateMenu();
MenuOptions3DViewHandle = CreateMenu();
MenuOptionsVertexMarkersHandle = CreateMenu();
MenuOptionsShowHideHandle = CreateMenu();
MenuOptionsMeasurementHandle = CreateMenu();
MenuHelpHandle = CreateMenu();
// END
}
/*
Function: ProcessMenuCommand
What it does: Processes menu commands as received from WS_COMMAND.
Parameters:
The routine: Stage 1 - filter the results based on the menu command's ID.
Stage 2 - perform the action based on this.
Return value: Nothing - if it fails, use MessageBox to mention what problem was encountered.
Remarks: There's a lot of repetion expected so form templates to speed the process up.
To do: Write this function. Use the defines at the top to make it easier to identify the menu command.
*/
/*
Function: QuitMenus
What it does: Destroys menus, freeing resources that the menus use (used upon closing).
Parameters: None.
The routine: Stage 1 - repeatedly call "DestroyMenu" to free the resources.
Return value: Nothing - if it fails, use MessageBox to mention what problem was encountered.
Remarks: There's a lot of repetion expected so form templates to speed the process up.
To do: Add more items whenever new ones are used.
*/
void QuitMenus()
{
// Even DestroyMenu is being flagged as undeclared
DestroyMenu(MenuMainHandle); // destroys the menu, freeing its resources
DestroyMenu(MenuFileHandle);
DestroyMenu(MenuEditHandle);
DestroyMenu(MenuViewHandle);
DestroyMenu(MenuObjectHandle);
DestroyMenu(MenuObjectNew2DShapeHandle);
DestroyMenu(MenuObjectNew3DShapeHandle);
DestroyMenu(MenuToolsHandle);
DestroyMenu(MenuOptionsHandle);
DestroyMenu(MenuOptions2DViewsHandle);
DestroyMenu(MenuOptions3DViewHandle);
DestroyMenu(MenuOptionsVertexMarkersHandle);
DestroyMenu(MenuOptionsShowHideHandle);
DestroyMenu(MenuOptionsMeasurementHandle);
DestroyMenu(MenuHelpHandle);
}
These are the errors I'm getting: Code: 1>------ Build started: Project: 3D modeling program, Configuration: Debug Win32 ------
1>Compiling...
1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>Menus.c
1>.\Menus.c(200) : error C2061: syntax error : identifier 'MenuMainHandle'
1>.\Menus.c(200) : error C2059: syntax error : ';'
1>.\Menus.c(202) : error C2061: syntax error : identifier 'MenuFileHandle'
1>.\Menus.c(202) : error C2059: syntax error : ';'
1>.\Menus.c(203) : error C2061: syntax error : identifier 'MenuEditHandle'
1>.\Menus.c(203) : error C2059: syntax error : ';'
1>.\Menus.c(204) : error C2061: syntax error : identifier 'MenuViewHandle'
1>.\Menus.c(204) : error C2059: syntax error : ';'
1>.\Menus.c(205) : error C2061: syntax error : identifier 'MenuObjectHandle'
1>.\Menus.c(205) : error C2059: syntax error : ';'
1>.\Menus.c(206) : error C2061: syntax error : identifier 'MenuObjectNew2DShapeHandle'
1>.\Menus.c(206) : error C2059: syntax error : ';'
1>.\Menus.c(207) : error C2061: syntax error : identifier 'MenuObjectNew3DShapeHandle'
1>.\Menus.c(207) : error C2059: syntax error : ';'
1>.\Menus.c(208) : error C2061: syntax error : identifier 'MenuToolsHandle'
1>.\Menus.c(208) : error C2059: syntax error : ';'
1>.\Menus.c(209) : error C2061: syntax error : identifier 'MenuOptionsHandle'
1>.\Menus.c(209) : error C2059: syntax error : ';'
1>.\Menus.c(210) : error C2061: syntax error : identifier 'MenuOptions2DViewsHandle'
1>.\Menus.c(210) : error C2059: syntax error : ';'
1>.\Menus.c(211) : error C2061: syntax error : identifier 'MenuOptions3DViewHandle'
1>.\Menus.c(211) : error C2059: syntax error : ';'
1>.\Menus.c(212) : error C2061: syntax error : identifier 'MenuOptionsVertexMarkersHandle'
1>.\Menus.c(212) : error C2059: syntax error : ';'
1>.\Menus.c(213) : error C2061: syntax error : identifier 'MenuOptionsShowHideHandle'
1>.\Menus.c(213) : error C2059: syntax error : ';'
1>.\Menus.c(214) : error C2061: syntax error : identifier 'MenuOptionsMeasurementHandle'
1>.\Menus.c(214) : error C2059: syntax error : ';'
1>.\Menus.c(215) : error C2061: syntax error : identifier 'MenuHelpHandle'
1>.\Menus.c(215) : error C2059: syntax error : ';'
1>.\Menus.c(219) : error C2061: syntax error : identifier 'testBMP'
1>.\Menus.c(219) : error C2059: syntax error : ';'
1>.\Menus.c(221) : error C2061: syntax error : identifier 'MenuFileInfo'
1>.\Menus.c(221) : error C2059: syntax error : ';'
1>.\Menus.c(222) : error C2061: syntax error : identifier 'MenuFileNewInfo'
1>.\Menus.c(222) : error C2059: syntax error : ';'
1>.\Menus.c(223) : error C2061: syntax error : identifier 'MenuFileOpenInfo'
1>.\Menus.c(223) : error C2059: syntax error : ';'
1>.\Menus.c(224) : error C2061: syntax error : identifier 'MenuFileSaveInfo'
1>.\Menus.c(224) : error C2059: syntax error : ';'
1>.\Menus.c(225) : error C2061: syntax error : identifier 'MenuFileSaveAsInfo'
1>.\Menus.c(225) : error C2059: syntax error : ';'
1>.\Menus.c(227) : error C2061: syntax error : identifier 'MenuEditInfo'
1>.\Menus.c(227) : error C2059: syntax error : ';'
1>.\Menus.c(228) : error C2061: syntax error : identifier 'MenuEditUndoInfo'
1>.\Menus.c(228) : error C2059: syntax error : ';'
1>.\Menus.c(245) : error C2143: syntax error : missing '{' before '*'
1>.\Menus.c(245) : warning C4431: missing type specifier - int assumed. Note: C no longer supports default-int
1>.\Menus.c(245) : warning C4218: nonstandard extension used : must specify at least a storage class or a type
1>.\Menus.c(476) : error C2065: 'MenuMainHandle' : undeclared identifier
1>.\Menus.c(476) : warning C4013: 'CreateMenu' undefined; assuming extern returning int
1>.\Menus.c(478) : error C2065: 'MenuFileHandle' : undeclared identifier
1>.\Menus.c(479) : error C2065: 'MenuEditHandle' : undeclared identifier
1>.\Menus.c(480) : error C2065: 'MenuViewHandle' : undeclared identifier
1>.\Menus.c(481) : error C2065: 'MenuObjectHandle' : undeclared identifier
1>.\Menus.c(482) : error C2065: 'MenuObjectNew2DShapeHandle' : undeclared identifier
1>.\Menus.c(483) : error C2065: 'MenuObjectNew3DShapeHandle' : undeclared identifier
1>.\Menus.c(484) : error C2065: 'MenuToolsHandle' : undeclared identifier
1>.\Menus.c(485) : error C2065: 'MenuOptionsHandle' : undeclared identifier
1>.\Menus.c(486) : error C2065: 'MenuOptions2DViewsHandle' : undeclared identifier
1>.\Menus.c(487) : error C2065: 'MenuOptions3DViewHandle' : undeclared identifier
1>.\Menus.c(488) : error C2065: 'MenuOptionsVertexMarkersHandle' : undeclared identifier
1>.\Menus.c(489) : error C2065: 'MenuOptionsShowHideHandle' : undeclared identifier
1>.\Menus.c(490) : error C2065: 'MenuOptionsMeasurementHandle' : undeclared identifier
1>.\Menus.c(491) : error C2065: 'MenuHelpHandle' : undeclared identifier
1>.\Menus.c(521) : warning C4013: 'DestroyMenu' undefined; assuming extern returning int
1>.\Menus.c(521) : error C2065: 'MenuMainHandle' : undeclared identifier
1>.\Menus.c(522) : error C2065: 'MenuFileHandle' : undeclared identifier
1>.\Menus.c(523) : error C2065: 'MenuEditHandle' : undeclared identifier
1>.\Menus.c(524) : error C2065: 'MenuViewHandle' : undeclared identifier
1>.\Menus.c(525) : error C2065: 'MenuObjectHandle' : undeclared identifier
1>.\Menus.c(526) : error C2065: 'MenuObjectNew2DShapeHandle' : undeclared identifier
1>.\Menus.c(527) : error C2065: 'MenuObjectNew3DShapeHandle' : undeclared identifier
1>.\Menus.c(528) : error C2065: 'MenuToolsHandle' : undeclared identifier
1>.\Menus.c(529) : error C2065: 'MenuOptionsHandle' : undeclared identifier
1>.\Menus.c(530) : error C2065: 'MenuOptions2DViewsHandle' : undeclared identifier
1>.\Menus.c(531) : error C2065: 'MenuOptions3DViewHandle' : undeclared identifier
1>.\Menus.c(532) : error C2065: 'MenuOptionsVertexMarkersHandle' : undeclared identifier
1>.\Menus.c(533) : error C2065: 'MenuOptionsShowHideHandle' : undeclared identifier
1>.\Menus.c(534) : error C2065: 'MenuOptionsMeasurementHandle' : undeclared identifier
1>.\Menus.c(535) : error C2065: 'MenuHelpHandle' : undeclared identifier
1>Generating Code...
__________________ High elevation is the best elevation. The higher, the better the view! My computer: XP Pro SP3, 3.17 GHz C2D CPU, 4 GB DDRII800 RAM (3 GB effective), X-Fi Platinum sound, GeForce 7600 GT, 1920x1440 resolution, 250 GB HDD, Visual C++ 2008 Express |
| ulillillia is offline | |
| | #2 |
| Registered User Join Date: Nov 2006 Location: japan
Posts: 102
| Could you please point were is line 245 of Menus.c ? (So we can have a clue)
__________________ Mac OS 10.6 Snow Leopard : Darwin |
| nacho4d is offline | |
| | #3 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| You are not including windows.h in your menus.c - so any type defined by windows (such as handles for menus) is not defined in this file. -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. |
| matsp is offline | |
| | #4 |
| Math wizard Join Date: Dec 2006 Location: Minot, ND, USA
Posts: 516
| Don't I have Windows.h defined in the main file - shouldn't that be included in everything that follows, including my own files? Or, since I'm not familiar with having multiple files for a project (I'm used to putting all files in a single file (With that, the line count easily ends up over 10,000.).).
__________________ High elevation is the best elevation. The higher, the better the view! My computer: XP Pro SP3, 3.17 GHz C2D CPU, 4 GB DDRII800 RAM (3 GB effective), X-Fi Platinum sound, GeForce 7600 GT, 1920x1440 resolution, 250 GB HDD, Visual C++ 2008 Express |
| ulillillia is offline | |
| | #5 |
| and the Hat of Ass Join Date: Dec 2007
Posts: 730
| Umm...yeah. DON'T do this: Code: #include "Menus.c" // this problematic file is at the end |
| rags_to_riches is offline | |
| | #6 |
| Math wizard Join Date: Dec 2006 Location: Minot, ND, USA
Posts: 516
| Yeah, I figured that out due to a double definition. I've got everything working now. Thanks. Now I can get going on this project!
__________________ High elevation is the best elevation. The higher, the better the view! My computer: XP Pro SP3, 3.17 GHz C2D CPU, 4 GB DDRII800 RAM (3 GB effective), X-Fi Platinum sound, GeForce 7600 GT, 1920x1440 resolution, 250 GB HDD, Visual C++ 2008 Express |
| ulillillia is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| This is driving me nuts... | jesin | C Programming | 5 | 11-22-2005 05:17 AM |
| This is driving me nuts. | Matt13 | C Programming | 3 | 03-25-2004 10:55 AM |
| i can't fix it! its driving me nuts | faxtoaster | C Programming | 2 | 07-10-2003 05:46 PM |
| This compiler is driving me nuts | martin_00 | C Programming | 32 | 12-31-2002 03:25 PM |
| driving me nuts | boontune | C++ Programming | 3 | 10-07-2002 04:35 AM |