don't understand compile-time error 
Author Message
 don't understand compile-time error

Hello all...

I'm new to programming in C, so please accept my apology for
what could be a simple problem and a waste of a post.

I'm getting a compile-time error that I do not understand.
Specifically, I'm getting 7 syntax errors for 7 simple
variable declarations in main().  The exact error states:
"declaration may not appear after executable statement in
block."  What's really confusing me is that there is no
executable code located before these variable declarations
in main().  The only thing before these declarations are
four #includes, two of which are my own header files, and
a structure definition.  I've commented out the structure
definition and (from what I can see) all other possible
code that is causing a conflict.  I still get the 7 syntax
errors when I compile.  Is there a general rule-of-thumb
that applies to this specific error?

Once again, I realize this is probably very basic problem
amidst more advanced questions, but I thought I'd give it
a try.

Any help would be greatly appreciated.

Mark Bramer



Thu, 10 May 2001 03:00:00 GMT  
 don't understand compile-time error

: Hello all...

: I'm new to programming in C, so please accept my apology for
: what could be a simple problem and a waste of a post.

: I'm getting a compile-time error that I do not understand.
: Specifically, I'm getting 7 syntax errors for 7 simple
: variable declarations in main().  The exact error states:
: "declaration may not appear after executable statement in
: block."  What's really confusing me is that there is no
: executable code located before these variable declarations
: in main().  The only thing before these declarations are
: four #includes, two of which are my own header files, and
: a structure definition.  I've commented out the structure
: definition and (from what I can see) all other possible
: code that is causing a conflict.  I still get the 7 syntax
: errors when I compile.  Is there a general rule-of-thumb
: that applies to this specific error?

The error's unambiguous, so there's someting odd in your
code or header files.  Try running the pre-processor by
itself (most compilers have a switch to do this) and take
a look at the resulting source file.

Will



Fri, 11 May 2001 03:00:00 GMT  
 don't understand compile-time error


Quote:

>Hello all...

>I'm new to programming in C, so please accept my apology for
>what could be a simple problem and a waste of a post.

>I'm getting a compile-time error that I do not understand.
>Specifically, I'm getting 7 syntax errors for 7 simple
>variable declarations in main().  The exact error states:
>"declaration may not appear after executable statement in
>block."  What's really confusing me is that there is no
>executable code located before these variable declarations
>in main().  The only thing before these declarations are
>four #includes, two of which are my own header files, and

#include files could conceivably contain executable code.  I mean,
yours might, although library ones probably don't,   but more
importantly, from what you've posted it sounds like you might have put
your include files inside main.  This is incorrect.  They should
probably just go on the first line, before main and everything else.

Quote:
>a structure definition.  I've commented out the structure
>definition and (from what I can see) all other possible
>code that is causing a conflict.  I still get the 7 syntax
>errors when I compile.  Is there a general rule-of-thumb
>that applies to this specific error?

For best results, post the problem code.  If it's very long, try to
include only the relevant portions.  Keep reading this newsgroup!

Quote:
>Once again, I realize this is probably very basic problem
>amidst more advanced questions, but I thought I'd give it
>a try.

>Any help would be greatly appreciated.

>Mark Bramer

Hope this helps
GW


Fri, 11 May 2001 03:00:00 GMT  
 don't understand compile-time error

Quote:
>I'm getting a compile-time error that I do not understand.
>Specifically, I'm getting 7 syntax errors for 7 simple
>variable declarations in main().  The exact error states:
>"declaration may not appear after executable statement in
>block."  What's really confusing me is that there is no
>executable code located before these variable declarations
>in main().  The only thing before these declarations are
>four #includes, two of which are my own header files, and
>a structure definition.  I've commented out the structure
>definition and (from what I can see) all other possible
>code that is causing a conflict.  I still get the 7 syntax
>errors when I compile.  Is there a general rule-of-thumb
>that applies to this specific error?

The rule of thumb is to post the code *itself*, not your description
of the code.  We MUST see *exactly* what the compiler "saw".  Otherwise,
we are reduced to guessing, and there is no place for this kind of
guesswork in C programming.

Dan
--
Dan Pop
CERN, IT Division

Mail:  CERN - EP, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland



Fri, 11 May 2001 03:00:00 GMT  
 don't understand compile-time error


Quote:

>Hello all...

>I'm new to programming in C, so please accept my apology for
>what could be a simple problem and a waste of a post.

>I'm getting a compile-time error that I do not understand.
>Specifically, I'm getting 7 syntax errors for 7 simple
>variable declarations in main().  The exact error states:
>"declaration may not appear after executable statement in
>block."  What's really confusing me is that there is no
>executable code located before these variable declarations
>in main().  The only thing before these declarations are
>four #includes, two of which are my own header files, and
>a structure definition.  I've commented out the structure
>definition and (from what I can see) all other possible
>code that is causing a conflict.  I still get the 7 syntax
>errors when I compile.  Is there a general rule-of-thumb
>that applies to this specific error?

>Once again, I realize this is probably very basic problem
>amidst more advanced questions, but I thought I'd give it
>a try.

>Any help would be greatly appreciated.

>Mark Bramer

Is it possible for you to include your code in your post?

cheers



Fri, 11 May 2001 03:00:00 GMT  
 don't understand compile-time error

Quote:

> I'm getting a compile-time error that I do not understand.
> Specifically, I'm getting 7 syntax errors for 7 simple
> variable declarations in main().

Hi Mark Bramer,

Please show us the code in question. It would be ideal if you
could create a short yet complete test "main()" that still reproduces
the errors. That way we know exactly what you're dealing with and
can maybe do some tests of out own.

Quote:
> The exact error states:
> "declaration may not appear after executable statement in
> block."

Yep, this requires a good look at the code. Somehow you managed to
sneak in a statement before or into the declarations. Typically
your compiler is very good at spotting these things :-)

Stephan
(initiator of the campaign against grumpiness in c.l.c)



Fri, 11 May 2001 03:00:00 GMT  
 don't understand compile-time error
As others have said here, please post the code in question
(including all of your header files).

You should also check your headers for null stmts like
        ;
and
        {}

as these will be taken as executable statements (albeit no-ops).
Also look for incomplete function prototypes that might be taken as a function call.

Quote:

>Hello all...

>I'm new to programming in C, so please accept my apology for
>what could be a simple problem and a waste of a post.

>I'm getting a compile-time error that I do not understand.
>Specifically, I'm getting 7 syntax errors for 7 simple
>variable declarations in main().  The exact error states:
>"declaration may not appear after executable statement in
>block."  What's really confusing me is that there is no
>executable code located before these variable declarations
>in main().  The only thing before these declarations are
>four #includes, two of which are my own header files, and
>a structure definition.  I've commented out the structure
>definition and (from what I can see) all other possible
>code that is causing a conflict.  I still get the 7 syntax
>errors when I compile.  Is there a general rule-of-thumb
>that applies to this specific error?

>Once again, I realize this is probably very basic problem
>amidst more advanced questions, but I thought I'd give it
>a try.

>Any help would be greatly appreciated.

>Mark Bramer

Lew Pitcher
System Consultant, Delivery Systems Architecture
Toronto Dominion Bank


(Opinions expressed are my own, not my employer's.)



Fri, 11 May 2001 03:00:00 GMT  
 don't understand compile-time error

Hello all again...

I tried to post last night letting you all know that the
problem has been solved, but my message was bounced back.

Anyway, thanks to all who offered help.  I will definitely
post my code the next time I have a specific question like
this.  Just minutes before I received the first few posts
offering help, I solved the problem on my own.

Once again, thanks to all and I will make sure my thread-killing
post gets through when I send it next time so you guys don't
have to take up more posts than necessary.

Mark Bramer



Fri, 11 May 2001 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. help!! Errors I don't understand

2. An error message I don't understand...

3. I don't understand this link error ...

4. don't understand error message

5. Don't understand why I am getting the C2236 error

6. Linker Error (I don't understand)

7. Don't understand what's Functions

8. Don't understand what's Functions

9. I don't understand the syntax.

10. Please help, I don't understand

11. I don't understand...

12. I don't understand

 

 
Powered by phpBB® Forum Software