Sign in to follow this  

Why won't this work?

This topic is 4548 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to compile a Win32 application using Cpp and Dev-Cpp. I only get one error when I try to compile, "parse error before `;' token". Dev-Cpp tells me that the error is in the last line of my CreateWindow function. I know a parse error is a syntax error, but I don't see anything wrong with my syntax. Here is my CreateWindow function. Can you tell me what is wrong? hWnd=CreateWindow( APPTITLE, APPTITLE, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 500, 400, NULL, NULL, hInstance, NULL); I wasn't sure how to put it in the scroll-box. Thanks!

Share this post


Link to post
Share on other sites
I think that its on the last line because thats where the command ends. I don't think it means that the problem is with that NULL, I think its saying that there is a problem with the command that ends on that line. I could be wrong though..

Share this post


Link to post
Share on other sites
I've gone over my entire piece of code, APPTITLE was defined right, there wasn't anything wrong with CreateWindow, I couldn't find anything else wrong, and I still get the error "parse error before `;' token". Do I need to type something in other than NULL on the last line? Any more suggestions would be greatly appreciated.

Share this post


Link to post
Share on other sites
Your code is fine as long as you have something like:

#define APPTITLE "My Title"

I just copy and pasted your code into a dev cpp project and it worked fined compile wise. Check the lines before that statement and check to make sure your APPTITLE is defined correctly. Compilers aren't 'smart', they can mislead you will errors due to previous syntax problems. Good luck!

Share this post


Link to post
Share on other sites
I got it! I was ending #define APPTITLE with a ; now I'm getting a lot of linker errors, but i'm going to fix those later because ive been working on this problem for so long... thanks for helping everyone!!!

Share this post


Link to post
Share on other sites
There's another good reason in C++ to use const identifiers instead of #defines for constants; if there's a problem with the definition, the error will be flagged in the definition.

const char* APPTITLE = "My Application";

Share this post


Link to post
Share on other sites

This topic is 4548 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this