PDA

View Full Version : Terrible unidentified problem!



Momergil
27th August 2011, 01:01
Hello!

Something strange happened with my software.

I was editing it quite normally, everything running fine, when in the last rebuild, two message errors appeared, showing problems in files that I simply didn't touch!

To give an idea, one of the problems say "/home/martin/Documentos/Programas Qt/M/mClock/../../../../QtSDK/Desktop/Qt/473/gcc/include/QtGui/qcalendarwidget.h:52: error: expected initializer before ‘typedef’"

But QCalendarWidget is simply called by the software in order to put a calendar in the MainWindow, while I simply didn't touch in the part regarding it in the software since two weeks!

Not just that, but the same problem is appointed to one of my classes, while this class, once again, wasn't touch in weeks and was working fine till now! :

/home/martin/Documentos/Programas Qt/M/mClock/clocksound.h:8: error: expected initializer before ‘class’

There is simply no problem with it. As I sad, I didn't even touch in this files and now they are reporting problems. My recent edits were all made in a different class, and they were all common changes that I already know how to do (i.e. nothing special or difficult).

I simply don't know what is happening. Does somebody knows something about? I tried to comment the recent edits, including, and nothing changed.


Thanks!

helloworld
27th August 2011, 01:49
Make sure that you don't have a missing semicolon at the end of a class declaration somewhere else in your project.



#ifndef MYCLASS_H
#define MYCLASS_H

class MyClass
{
public:
// ...

} // <-- oops

#endif // MYCLASS_H

DanH
27th August 2011, 03:05
Yep, a missing semicolon in one of your includes is the most likely cause.

SixDegrees
27th August 2011, 10:26
Also, of course - if it was working before, undo your recent changes to the point where it was working, and ensure that the problem is somewhere within your code. Assuming you're using a revision control system, this is a quick, simple check.

Momergil
27th August 2011, 15:36
Yep, a missing semicolon in one of your includes is the most likely cause.

Nops, that's not the problem. I revised class by class and al semicolon are in place.


Also, of course - if it was working before, undo your recent changes to the point where it was working, and ensure that the problem is somewhere within your code. Assuming you're using a revision control system, this is a quick, simple check.

I tried to do this. unfortunately, for this software I'm not doing a revision control system (the unique one that I'm not doing it, and the only one with such problem!). But, as I sad, I commented the changes and it was for no good use. Well, I'll try to delete literally everything, let us see what happens.

Any case, don't somebody have another idea?

SixDegrees
27th August 2011, 16:20
My money is on a change that you've made, deliberately or not. The story - everything worked, you made some changes, now it doesn't work - is consistent with that and little else. The chances of some file outside your project changing is near zero. So look at your code and scan for errors. Try eliminating ALL include statements and repace external references with forward declarations to narrow the compiler's attention to your own files, which is almost certainly where the problem lies. As others have said, it's probably a misplaced semi-colon, or perhaps a run-on string declaration, but there's some syntactical error there somewhere. The gripes about problems in external files are not the cause; they're a symptom.

You should have the problem narrowed down to one or two files, a header file and possibly a source file. Delete everything but the include statements; compilation will likely succeed, proving that the problem is in the code you got rid of and not any of the external chaff. Replace your code, incrementally if possible, until the problem is isolated.

Momergil
27th August 2011, 17:05
My money is on a change that you've made, deliberately or not. The story - everything worked, you made some changes, now it doesn't work - is consistent with that and little else. The chances of some file outside your project changing is near zero. So look at your code and scan for errors. Try eliminating ALL include statements and repace external references with forward declarations to narrow the compiler's attention to your own files, which is almost certainly where the problem lies. As others have said, it's probably a misplaced semi-colon, or perhaps a run-on string declaration, but there's some syntactical error there somewhere. The gripes about problems in external files are not the cause; they're a symptom.

You should have the problem narrowed down to one or two files, a header file and possibly a source file. Delete everything but the include statements; compilation will likely succeed, proving that the problem is in the code you got rid of and not any of the external chaff. Replace your code, incrementally if possible, until the problem is isolated.

How, that is trully a technical help xDD

Anyway, here is what I did: I created a new project and included the same files of the previous software (the one with the problem), but without the last edits. The software run fine. Than, I did some basic edits (part of those I did before), and the same problem appeared. I, than, deleted those last edits, and the problem persisted.

\o/

squidge
27th August 2011, 17:57
You've not been copying and pasting have you? This can introduce seemingly invisible characters that your editor doesn't display, but your compiler can fall over on.

SixDegrees
27th August 2011, 19:32
How, that is trully a technical help xDD

Anyway, here is what I did: I created a new project and included the same files of the previous software (the one with the problem), but without the last edits. The software run fine. Than, I did some basic edits (part of those I did before), and the same problem appeared. I, than, deleted those last edits, and the problem persisted.

\o/

OK. So now you know that the problem is with the code you added. Try removing it bit by bit - or start over and add it back bit by bit - until you find the problematic section.

Momergil
28th August 2011, 01:19
You've not been copying and pasting have you? This can introduce seemingly invisible characters that your editor doesn't display, but your compiler can fall over on.

Mas, that was exactly half of the edits that, after them, made the problem appears. The case was that, in a class called from a PushButton in the MainWindow, two different QWidgets were supposed to appear. Having one of the ready, I decided to create a similar function to open the second QWidget, just with the obvious difference that it was called by a different PushButton. Than I did the necessary changes and bang! The problem appeared next time I did the compyling.

But I'm not sure if your explanation is the correct one, because recently I did a test: I run the software almost as it was before the problem appears, OK. Than I changed a declaration of one boolean variable in the .h file of one of the classes and the problem return. So it seems that whatever change I did from that point, the problem would appear. Of course, it may still be the case my software was already with this invisible characters, but I have no way of knowing it.

Added after 4 minutes:


OK. So now you know that the problem is with the code you added. Try removing it bit by bit - or start over and add it back bit by bit - until you find the problematic section.


Yep, this is what I did minutes ago: I copied from a version that don't show the problem and deleted all of the classes with the exception of MainWindow. In one of my deletions, one of the problem dissapeared, but I could find what changed. Than the last of the problems (the one pointing to the QCalendarWidget.h) disappeared when I deleted a #include <QString> from the mainwindow.h. When I put it back, the problem returned. Than I changed the position (before #include <QMainWindow>, after #include <QCalendarWidget>) and I found out that that changes completely the problems. In one of the cases, the compiler detected 250+ problems!!!

What is problematic is that the QString instantiation is quite necessary for the MainWindow.

Do you have any tip of how should I proceed?

In case squidge being right, I think that the best thing I can do is to start again and rewrite the software peace by peace manually, but that means the recreation of almost 10 classes! I hope there is a better thing to do.


Momergil

Added after 27 minutes:

Yeah! I fixed the problem!

But I still don't know exactly what was it...

Essentially what I did is, after knowing that the place where I put the include in the .h files could create or solve problems, I decided to do a "clean" in my software, erasing all unnecessary includes, specially those that came from the initial software (I build this one based in another one, just changing the functions and variables). I found out, e.g., that QMainWindow was included twice in the mainwindow.h and so on. Than changing the place of QLabel and QString from header to header, I could finally find an organization that maintain all what I did and its working.

I just hope this problem will not return anymore...


Anyway, thanks for the help!


God bless,

Momergil