Okay, so I'm using a tutorial(the part I'm on is found at http://www.winprog.org/tutorial/menus.html), and I did most things it tells me to do so I can add an icon and menu to my window(I excluded the second popup and don't have the same variable names/numeric identifiers).
However, it won't compile.
I don't know why.
The errors are
1 2 3 4 5 6 7 8 9 10 11 12
Error 1 error C2059: syntax error : 'constant' c:\documents and settings\randy\desktop\xbla\resource.rc 3
Error 4 error C2059: syntax error : 'constant' c:\documents and settings\randy\desktop\xbla\resource.rc 10
Error 10 error C2065: 'g_szClassName' : undeclared identifier c:\documents and settings\randy\desktop\xbla\maini.cpp 43
Error 12 error C2065: 'g_szClassName' : undeclared identifier c:\documents and settings\randy\desktop\xbla\maini.cpp 56
Error 9 error C2143: syntax error : missing ')' before ';' c:\documents and settings\randy\desktop\xbla\maini.cpp 39
Error 2 error C2143: syntax error : missing ';' before '{' c:\documents and settings\randy\desktop\xbla\resource.rc 4
Error 3 error C2447: '{' : missing function header (old-style formal list?) c:\documents and settings\randy\desktop\xbla\resource.rc 4
Error 11 error C2660: 'LoadIconA' : function does not take 6 arguments c:\documents and settings\randy\desktop\xbla\maini.cpp 44
Warning 5 warning C4129: 'D' : unrecognized character escape sequence c:\documents and settings\randy\desktop\xbla\resource.rc 10
Warning 7 warning C4129: 'M' : unrecognized character escape sequence c:\documents and settings\randy\desktop\xbla\resource.rc 10
Warning 8 warning C4129: 'M' : unrecognized character escape sequence c:\documents and settings\randy\desktop\xbla\resource.rc 10
Warning 6 warning C4129: 'R' : unrecognized character escape sequence c:\documents and settings\randy\desktop\xbla\resource.rc 10
And frankly I don't understand why I get these errors. I've done nothing wrong that I know of, and can find no way to fix the things it says are wrong.
Can someone tell me how to get rid of these error messages, or at least why I'm getting them?
Actually, I managed to get rid of all the errors except the very first one. The warnings are still there, though.
Here's the .rc file:
1 2 3 4 5 6 7 8 9 10 11
#include "resource.h"
M_MAHMENU MENU //<-- Error 1 error C2059: syntax error : 'constant'
BEGIN
POPUP "&FILE"
Begin
MENUITEM "E&XIT", Mi_EXIT
END
END
I_MAHICON ICON "C:\Documents and Settings\Randy\My Documents\My Pictures\favicon.ico"
Is anything else defined with the value 101? The compiler doesn't always catch duplicates.
Here is the documentation on C2059 --
+++++++++++++++++++++++++++++
The token caused a syntax error.
To determine the cause, examine not only the line listed in the error message, but also the lines above it. The following example generates an error message for the line declaring j, but the true source of the error appears on the line just above it.
If examining the lines yields no clue to what the problem might be, try commenting out the line listed in the error message and possibly several lines above it.
If the error message occurs on a symbol immediately following a typedef variable, check that the variable is defined in the source code.
You may get C2059 if a symbol evaluates to nothing, as can occur when you compile with /Dsymbol=.
+++++++++++++++++++++++++++++
There are no lines above the error one that can be commented out to get rid of the error, commenting out the errored line causes even more errors, and I changed the numeric definition to 103, and it still had the error.
I don't know if either of those will sovle your syntax problem in the rc file, but as I said, I've looked through a lot of examples in win programming and I've never seen these two.
Err, I was told to write both of those in like that by the tutorial.
Besides, the Icon isn't having a problem, it's the menu(oddly enough, though, if I replace BEGIN and END with brackets, among the numerous errors that show up, the icon line gets the same Constant character error).
Your problem is beyond me. I'm pretty new to programming myself, but I've probably got a few months on you. However, it's gonna take one of the pros here to help you figure this out.
Could you please giv us an url to your tutorial or maybe the whole code (including ressource files, I hope it is not too big)?
That way the root of your error can be found much faster and easier than by looking at some bits of your code which are perhaps not even the actual reason for the error.
I happen to use the same tutorial that you are using, and quite frequently I come across errors when I copy code directly from the tutorial.
First off, are you using VC++? If you are then if you have an empty project, and you copy the tutorial source right into your project it will probably give you errors. For what reason, I don't know why; it's just what happens. I think it has something to do with how it links in resources. One thing I recommend that has worked out for me is to try creating a win32 application and manually adding the stuff from the tutorial with slight changes to match the syntax of VC++.
In the meantime, try this: taking off the unnecessary zeros from your definitions and always keep your definitions all caps.
#define M_MAHMENU 101
#define I_MAHICON 102
#define MI_EXIT 201
Also, change your "Begin" after 'POPUP "&FILE"' to all caps.
As for your warnings, in your path for your icon, after each "\" character it is expecting an escape character. Try putting your icon in the folder that your .rc file is in then you won't need the entire path; just "favicon.ico". If you really want the entire path in there, you will need two backslashes in a row: "C:\\Documents and Settings\\Randy\\My Documents\\My Pictures\\favicon.ico".
Sry, for asking in my last post again for the url. I just clicked on the link and as it didn't work I asked for it again. I didn't look at the url itself at all and didn't see that ")," was added because of the automatic url parser. My fault...
If benzensulfonic's solutions works, as it should if it worked for him ;), please notify the author of this tutorial so that it can be corrected for future readers.
You have the same problem as the TS in this post: http://cplusplus.com/forum/windows/12777/#msg61367
You should be able to fit in this solution in your project. You could also convert char to wchar_t, but it shouldn't be necessary in your case.
If there are any other problems just ask again.
PS: Please notify the author of the tutorial. Else this might pop up again and again.
Actually, this tutorial was intended for generic win32 on a typical windows xp machine. With all of the unicode strings and whatnot added in for professional development with Visual Studio, the tutorial is almost outdated. If you are going to use this tutorial, then you have to alter the code based on what the compiler is telling you to do. It's too much to ask the maker of the tutorial to alter every lesson based on unicode compatibility. In my opinion, you either have to deal with it, or just find another tutorial :)