[lug] Obscure gcc question

D. Stimits stimits at idcomm.com
Wed Apr 3 01:59:40 MST 2002


"Scott A. Herod" wrote:
> 
> Hello,
> 
>   I bit of an obscure gcc ( and kdevelop ) question.  The version of
> kdevelop
> that my colleagues use does not terminate files with a newline.  As a
> consequence,
> gcc whines a lot about header files missing newlines.  This does not
> appear to be
> a warning that can be turned off with a compiler flag.  I think that it
> is possible
> to write code that does different things depending on whether the
> newline is there
> or not.  Certainly I can generate code that errors without it and only
> warns with
> it.  Below is my sample.  Can anyone suggest something that compiles
> differently
> depending on the existance of a newline at the end of a header file?

I have run into this when porting code that originally ran on VC++, and
it was terminated not with a newline but instead with the final line of
code. I never found an answer to it, just that g++ and gcc want the last
line to end with a newline. The easiest way around it seems to be to
just add it.

D. Stimits, stimits at idcomm.com

> 
> Scott
> 
> ----  test1.h: ( You may need to use tr -d "\n" to strip off the
> trailing newline. )
> #define WHAT_IS(a)  a \
> ----
> 
> ----  test2.h:
> int i = 3;
> ----
> 
> ----  main.C:
> #include <iostream>
> 
> #include "test1.h"
> #include "test2.h"
> 
> int main()
> {
>     cerr << WHAT_IS(5) << endl;
>     return 0;
> }
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug



More information about the LUG mailing list