-
November 28th, 2005, 12:59 PM
#1
unusual compiler error
first of all sorry for such general title, i dont know how to describe this problem
in my code i have a "define" and my document pointer
Code:
//defaults.h
...
#define SOME_NUMBER 20
...
//MyView.h line 10
...
CAppDoc* GetDocument() const;
...
when i change the value of SOME_NUMBER to, lets say, 21 the program wont compile and visual studio throws this errors
...MyView.h(10): error C2143: syntax error : missing ';' before '*'
...MyView.h(10): error C2501: 'MyView::CAppDoc' : missing storage-class or type specifiers
...MyView.h(10): error C2501: 'MyView::GetDocument' : missing storage-class or type specifiers
...MyView.h(10): warning C4183: 'GetDocument': missing return type; assumed to be a member function returning 'int'
BUT, when i comment line 10 , rebuild everything (with errors, naturally), and then uncomment and rebuild again it all works fine, no error, no warnings, no bugs in program
is this normal MS VS issue?
Last edited by l00p1n6; November 28th, 2005 at 02:07 PM.
Reason: added "compiler" to the title
-
November 28th, 2005, 01:41 PM
#2
Re: unusual error
First, change the title of the thread to mean something. You put "Unusual
error." Error in what.
Something like "Error when compiling"
Can you attach a small project that has the same problem?
You may be getting mixed with the Precompiled Headers. Show the Cpp file
that you are compiling with these headers.
-
November 28th, 2005, 02:06 PM
#3
Re: unusual error
all my .h files have #ifndef _CLASS_NAME_ #define _CLASS_NAME_ and #endif _CLASS_NAME_ (where _CLASS_NAME_ is unique for each class) so i think that i dont get mixed with precompiled headers
-
November 28th, 2005, 02:15 PM
#4
Re: unusual error
Sorry, but my impression is that you want to play with us "guess what's in my code".
Anyhow, once "rebuild all" saves you, then rebuild all and "game over".
-
November 28th, 2005, 03:45 PM
#5
Re: unusual error
Originally Posted by ovidiucucu
Sorry, but my impression is that you want to play with us "guess what's in my code".
Anyhow, once "rebuild all" saves you, then rebuild all and "game over".
please mr., do not insult me so much:(
i have posted numerus problems in codeguru forums and almost all have been answered (those that werent, just showed me that im on the wrong track)
i would NEVER take time from fellow programers who voluntarely in their own spare time help programming beginners just to amuse myself
problem i'm facing is for my project, wich has a lot of code by now. that is the one reason i am not posting it. the other reason is my mentors "orders" (i dont know a better word): not to post my whole code for other people to solve my problems
thanks to all you guys (you too ovidiucucu), my project is at late beta phase. i have my brother testing it and am implementing some user friendly add-ons (tool-tips, nicer buttons, multiple screen resoulution support etc.)
i will post my whole project in code guru page (if they agree) after it gets accepted by my mentor so that all users can see my mistakes (it has more than 10 working versions)
now, about my problem... since i have just small changes to make(default itmem positions in formwiev) i will continue the way i do now:
1. change defined value,
2. rebuild,
3. comment the problematic line - 10 (actualy it is 57)
4. rebuild,
5. uncomment the problematic line
6. rebuild
7. look at dialog layout when program is running and repeat steps 1-7 if needed
regards
kresimir
Last edited by l00p1n6; November 28th, 2005 at 03:46 PM.
Reason: misspelled ovidiucucu, sorry
-
November 28th, 2005, 05:21 PM
#6
Re: unusual error
Are you working on mulitple computers?
Maybe time difference between the different computers.
Other than that, I'm thinking.....
-
November 28th, 2005, 07:18 PM
#7
Re: unusual error
phew, i think i did it
i tried compiling my code on my friend's computer and his computer did not support the workaround i used (coment, build, uncomment, build), so i concluded it is not totaly MS VS compiler error
then i decided to compare all files in project with the ones in previous version, and didnt found anything (maybe because my eyes were tired), next thing i tried was comparing all files in MS word, (copy-paste and save each source file in separate .doc file and then do comparison), but since i did quite a bit of cleaning since previous versions it was all messy and i gave up
next thing i did was searching the internet for "folder comparer" and i ran into veri usefull VS plugin on codeproject's pages "Web Report 2.1"... to cut the story the plugin showed new entry in newest version of the program (thank God i did the versioning thing) it was the line:
#include "MyView"
in CAppDoc.h file
i dont know how it came there or why (maybe because i use ctrl+c and ctrl+v too often
when i commented that line and run the compilation i was thrilled, i changed my "defaults.h" entries a bit and compiled again..... perfectly, without errors
with my problem solved im still puzzled: why did my comment-build, uncomment-build work?
btw my file "MyView.h" does contain
Code:
#ifndef _MY_VIEW_
#define _MY_VIEW_
...
//code
...
#endif //_MY_VIEW_
so i dont understand what was wrong
although my problem is solved, i would like your comments on the issue, please
thank you
kresimir
-
November 28th, 2005, 09:12 PM
#8
Re: unusual error
you can simply solve this problem as I always do.
include your document class at your MyView.h file.
it will probably looks like this :
#include "AppDoc.h"
CAppDoc* GetDocument();
-
November 28th, 2005, 10:32 PM
#9
Re: unusual error
Originally Posted by l00p1n6
although my problem is solved, i would like your comments on the issue, please
How can anyone comment when we didn't see your code?
All we can say is that you made a mistake.
Regards,
Paul McKenzie
-
November 28th, 2005, 11:29 PM
#10
Re: unusual error
Hi,
Check if you did this
#define SOME_NUMBER 21 ; //<- the semi-colon can cause this error I think
Good Luck
______________________________
To err is human, it's the computer that causes blunders !!!
DO: Dazzle me with your intelligence
DON'T : Confuse me with your bullshit
-
November 29th, 2005, 07:25 AM
#11
Re: unusual error
Originally Posted by Mustafa
Hi,
Check if you did this
#define SOME_NUMBER 21 ; //<- the semi-colon can cause this error I think
Good Luck
do this
add doc header file then add the view header file
for e.g
Code:
#include "SampleDosc.h"
#include "SampleView.h"
now compile ur pgm it won't give error.
If I Helped You, "Rate This Post"
Thanks
Guna
-
November 29th, 2005, 06:29 PM
#12
Re: unusual error
Originally Posted by Paul McKenzie
How can anyone comment when we didn't see your code?
All we can say is that you made a mistake.
by the "issue" i mean how is it posible that
1. you build a program and get errors
2. you comment one line of code (add "//" in the beginning of a line)
3. you build a program and get errors
4. you uncomment the same line of code (delete "//" in step 2.)
5. you build a program and get NO errors
please note "NO" in step 5.
and yes you are right (again), i did made a mistake
Originally Posted by suchuhui80
include your document class at your MyView.h file.
i do have that "include" in every view
Originally Posted by Mustafa
Check if you did this
#define SOME_NUMBER 21 ; //<- the semi-colon can cause this error I think
no i dont have that ";" at the end of #define directive
Originally Posted by Gunaamirthavelu
add doc header file then add the view header file
do you mean that it has to be done by that order?
because i almost always include .h file of appropriate class in .cpp file after "#include stdafx.h" (i dont want to mess with that 'cause VS puts it in every .cpp file by default)
the problem was in :
#include "MyView.h
in MyDocument.h
and it was solved (deleted that line), but the question still stays in place (i think)
why did comment-uncomment evade the error?
-
November 29th, 2005, 06:44 PM
#13
Re: unusual error
Who knows why your workaround worked. For some reason, the compiler thought the file that actually contained the error didn't need compiling the second time around.
Do a google search for "merge programs" or "diff programs". Personally I use a program called "WinMerge" to diff my files. Also, if you're using MSVC 6.0, there should be a program called "Windiff" that allows you to compare two files, side by side, highlighting the differences.
Viggy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|