"engvishal_jain" <[EMAIL PROTECTED]> wrote:
>
> Hi All,
> I am stuck with this simple code that uses #error
> No exe is form

#error is usually a signal that the program should not
compile. Strictly speaking, a C90 compiler is not
required to fail translation, but this was changed
under C99.

> and stupid gcc giving following error.

gcc isn't sentient, but it often shows more intelligence
than the people using it. ;-)

> Pls help me out
> -----------------------------------------------------------------
> #include<stdio.h>
> 
> int main(void)
> {
>       printf("BUG :::::::::::::::::::: %s : %d",__FILE__,__LINE__);
>       #error "Failed to inialize"
>         return 0;
> }
> ----------------------------------------------------------------
> OUTPUT
> $ gcc a.c
> a.c:6:10: #error "Failed to inialize"

This one is expected.

> a.c: In function `main':
> a.c:4: warning: return type of `main' is not `int'

Either you have a broken version of gcc, or your source
code above is not that of a.c.

> a.c:7:2: warning: no newline at end of file

This is a subtle requirement of the C language. Source
must end with a newline. Very few compilers enforce it.
gcc is simply warning you about it. If you didn't have
the #error directive, it would still compile. But the
solution is simple: add a newline.

The requirement stems from the fact that text streams
require a newline on some implementations. [There are
still line printers in this world that won't print
a line of text until it receives a newline.]

Note that some text editors give you the option of
always adding a newline at the end of a file.

-- 
Peter

Reply via email to