[lug] Obscure gcc question

Scott A. Herod herod at interact-tv.com
Tue Apr 2 17:44:50 MST 2002


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?

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;
}



More information about the LUG mailing list