weird error

G

Gernot Frisch

hi,

i don't even know how to desribe the error...

I have a Qt application. Now, there's a .cpp file that I reduced to:

// #include <somefile.h>
int i=45;
/*
long source code
*/


I get the error:
error before {
definition of function xy - parameters in old style?

And - it has to do with the // #include line, although this line _IS_
commented out!
Using /* */ comments would fix it, but I can't compile the project
anyway.
I use VC7.1.

Any ideas?

--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}

________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com
 
I

Ioannis Vranos

Gernot said:
hi,

i don't even know how to desribe the error...

I have a Qt application. Now, there's a .cpp file that I reduced to:

// #include <somefile.h>
int i=45;
/*
long source code
*/


I get the error:
error before {
definition of function xy - parameters in old style?

And - it has to do with the // #include line, although this line _IS_
commented out!
Using /* */ comments would fix it, but I can't compile the project
anyway.
I use VC7.1.

Well if it is commented out, then this #include exists in some other
project file(s) where it is not commented out.


Also it would be better if you pasted the definition of the function xy.
 
G

Gernot Frisch

Ioannis Vranos said:
Well if it is commented out, then this #include exists in some other
project file(s) where it is not commented out.


Also it would be better if you pasted the definition of the function
xy.

there is no function xy. Plus: the .cpp file consists of comments and
only one line: int i=32;
This is so not-funny...
-Gernot
 
V

Victor Bazarov

Gernot said:
there is no function xy. Plus: the .cpp file consists of comments and
only one line: int i=32;
This is so not-funny...
-Gernot

Make sure you blow away "precompiled headers" first. Or, simply put,
rebuild all.

If that doesn't help, make your compiler output the result of pre-
processing and analyze the file as the compiler sees it.

V
 
G

Gernot Frisch

Victor Bazarov said:
Make sure you blow away "precompiled headers" first. Or, simply
put,
rebuild all.

If that doesn't help, make your compiler output the result of pre-
processing and analyze the file as the compiler sees it.

Good idea, thank you!
 
K

Karl Heinz Buchegger

Gernot said:
there is no function xy. Plus: the .cpp file consists of comments and
only one line: int i=32;
This is so not-funny...

There seems to be some problem with your comments.
Try: Cut the now commented sections out of the source code.
Compile. There should be no problem.
No start inserting all the functions from the commented section
again, one function at a time. Recompile after every insert.

Using this technique you should be able to identify the problem
or at least get a better insight.
 
R

Richard Herring

Gernot Frisch said:
there is no function xy. Plus: the .cpp file consists of comments and
only one line: int i=32;

It was 45 a moment ago. Post the entire file. In particular, what
happens _before_ the #include?

Somehow you are including a combination of lines which produce something
resembling an "old-style" function definition such as

xy(i)
int i;
{
/* function body */
}
 
G

Gernot Frisch

it's soo weird! it says: unexpected #enddef and gives me this line:

--start of file--
// Comment
#ifndefe STD_HEADERS_INC_
#define STD_HEADERS_INC_ <--- that's the error line

...some #inlcude's here
#endif
// STD_HEADERS_INC_
--end of file--

there's no enddef in that line...
 
I

Ioannis Vranos

Gernot said:
it's soo weird! it says: unexpected #enddef and gives me this line:

--start of file--
// Comment
#ifndefe STD_HEADERS_INC_

It must be #ifndef
 
G

Gernot Frisch

Ioannis Vranos said:
It must be #ifndef

Was a typo when posting.
See: that's my stdafx.h now:
--SOF--
// comment
#ifndef STD_HEADERS_INC_
#define STD_HEADERS_INC_

/*
#pragma warning(disable:4067)
#include <qt.h>
#include <sof_qt_view.h>
#include <sof_qt_childwindow.h>
// #include "xwalls_doc.h"
// #define XPLATFORM
*/

#endif
// STD_HEADERS_INC_

--EOF--

e:\GeFr\Classes\Modules\Qt\23.que\xwalls\stdafx.h(4) : warning C4138:
'*/' wurde außerhalb des Kommentars gefunden
e:\GeFr\Classes\Modules\Qt\23.que\xwalls\stdafx.h(4) : error C2059:
Syntaxfehler: '/'
e:\GeFr\Classes\Modules\Qt\23.que\xwalls\stdafx.h(5) : fatal error
C1020: Unerwartetes #endif


if I remove all comments, I get the last error only, at the line:
#ifndef STD_HEADERS_INC_

I'm going insane here!
 
G

Gernot Frisch

One of the file got - don't ask how - only \n as line feeds - after
making it \r\n everything worked smoothly.
Oh boy - and one day of work is gone...
 
C

Chris Theis

Gernot Frisch said:
Was a typo when posting.
See: that's my stdafx.h now:
--SOF--
// comment
#ifndef STD_HEADERS_INC_
#define STD_HEADERS_INC_

/*
#pragma warning(disable:4067)
#include <qt.h>
#include <sof_qt_view.h>
#include <sof_qt_childwindow.h>
// #include "xwalls_doc.h"
// #define XPLATFORM
*/

#endif
// STD_HEADERS_INC_

--EOF--

e:\GeFr\Classes\Modules\Qt\23.que\xwalls\stdafx.h(4) : warning C4138:
'*/' wurde außerhalb des Kommentars gefunden
e:\GeFr\Classes\Modules\Qt\23.que\xwalls\stdafx.h(4) : error C2059:
Syntaxfehler: '/'
e:\GeFr\Classes\Modules\Qt\23.que\xwalls\stdafx.h(5) : fatal error
C1020: Unerwartetes #endif


if I remove all comments, I get the last error only, at the line:
#ifndef STD_HEADERS_INC_

I'm going insane here!

You´re running into problems with your comments or end-of-comment. Follow
the advice Karl Heinz Buchegger gave you systematically. Unfortunately the
code snippets you posted don´t help because the problem is hidden somewhere
deeper.

Chris
 
O

Old Wolf

Gernot said:
One of the file got - don't ask how - only \n as line feeds - after
making it \r\n everything worked smoothly.
Oh boy - and one day of work is gone...

I've noticed that in other compilers too, it amazes me.

Some other examples: if a #included file has its last line
not ending in a linefeed then there's a syntax error.
Or if a file has the first line ending in \n and then
subsequent lines in \r\n, the editor treats the \r\n as \n\n
(and saves it as such, if you re-save the file).

When I get weird problems like that, I run
'dos2unix foo.c; unix2dos foo.c' (or vice versa if I'm on unix).
 
R

Richard Herring

Old said:
I've noticed that in other compilers too, it amazes me.

Some other examples: if a #included file has its last line
not ending in a linefeed then there's a syntax error.
Or if a file has the first line ending in \n and then
subsequent lines in \r\n, the editor treats the \r\n as \n\n
(and saves it as such, if you re-save the file).

When I get weird problems like that, I run
'dos2unix foo.c; unix2dos foo.c' (or vice versa if I'm on unix).
I find a far more common problem is when a window pops up at the wrong
moment and I accidentally type a single letter just before the block of
comments at the head of a file. It's easily overlooked and can produce
some very confusing error messages.
 
O

Old Wolf

Richard said:
I find a far more common problem is when a window pops up at
the wrong moment and I accidentally type a single letter just
before the block of comments at the head of a file. It's
easily overlooked and can produce some very confusing error messages.

Yeah, that too. I seem to end up typing a '7' at the start of
the file, for some reason. But I've found it easy to track down
because the compiler will complain about the very first line of
the file, and it will stick out like a sore thumb in a
syntax-highlighting editor.

Another nasty one (I've had a variant of it) is finishing the
last declaration in a header with a comma instead of a
semicolon.
 
R

Richard Herring

Old said:
Yeah, that too. I seem to end up typing a '7' at the start of
the file, for some reason. But I've found it easy to track down
because the compiler will complain about the very first line of
the file,

Depends on the compiler, and the character. If it's a letter, it could
be the start of a declaration, and the complaint is usually about the
next non-comment line, somewhere deep in an included file.
and it will stick out like a sore thumb in a
syntax-highlighting editor.

Not if the statutory block of copyright notices, change log etc. etc.
has scrolled it off the top!
Another nasty one (I've had a variant of it) is finishing the
last declaration in a header with a comma instead of a
semicolon.
Missing the semicolon off a class definition has interesting effects,
too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,661
Latest member
FloridaHan

Latest Threads

Top