Public Group

# Why won't this work?

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

## 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 on other sites
How is APPTITLE defined? Did you maybe miss a quote?

##### Share on other sites
I'll check that, but the error is in the very last line, NULL);
is there anything wrong with that line?

##### 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 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 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 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 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";

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633768
• Total Posts
3013743
×