Re: cannot compile same code on RHL 7.2 and 9.0

Discussion in 'C Programming' started by Derk Gwen, Aug 12, 2003.

  1. Derk Gwen

    Derk Gwen Guest

    "Slavisa" <> wrote:
    # Yes, i have. Why ? Is that the problem ? Thats strange.

    # > Do you have a header file that ends in something like
    # > #endif
    # > without a new line after the #endif or some other final preprocessor
    # command?

    Depending on the compiler, if there is no end of line at the end of an included
    file, the preprocessor paste the last line onto the front of the next line of
    the including file.

    If you have something like
    #include "beta.h"
    #include "gamma.h"
    int omega(void) {...}<<EOF>>
    #ifndef beta_h
    #define beta_h
    int upsilon(void) {...}
    int zeta(void) {...}<<EOF>>

    Then on some systems, this is pasted into a source

    #ifndef beta_h
    #define beta_h
    int upsilon(void) {...}
    #endif int zeta(void) {...} int omega(void) {...}<<EOF>>

    Pasting int zeta... and int omega... onto one line is not a problem, because
    new lines are no more signficant than blanks to the compiler, but they are
    special for preprocessor instructions: pasting the C functions onto the same
    line as a preprocessor line can have all sorts of adverse effects.

    The problem could be something else of course, but I usually see these
    kinds of errors in this case, or in case of an omitted semicolon (;).

    Derk Gwen
    Haven't you ever heard the customer is always right?
    Derk Gwen, Aug 12, 2003
    1. Advertisements

  2. Nils Petter Vaskinn <> scribbled the following:
    > On Tue, 12 Aug 2003 00:18:57 +0000, Derk Gwen wrote:
    >> ------------alpha.c
    >> #include "beta.h"
    >> #include "gamma.h"
    >> int omega(void) {...}<<EOF>>
    >> ------------beta.h
    >> #ifndef beta_h
    >> #define beta_h
    >> int upsilon(void) {...}
    >> #endif<<EOF>>
    >> ------------gamma.h
    >> int zeta(void) {...}<<EOF>>

    > alpha, beta, gamma, epsilon .....

    > whatever happened to foo, bar and baz? I thought they where the
    > accepted names :)

    > Any day now people are gonna start renaming i to loop_var and n to count,
    > we're doomed I say, doomed.

    I normally use foo and bar, but if I know I'm going to use exactly
    four names, I use om, mane, padme and hum. I once used the variable
    name janisistuimaassatorkkuentorkkuen in a Pascal homework program.

    /-- Joona Palaste () ---------------------------\
    | Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
    | W++ B OP+ |
    \----------------------------------------- Finland rules! ------------/
    "C++. C++ run. Run, ++, run."
    - JIPsoft
    Joona I Palaste, Aug 19, 2003
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Slavisa

    cannot compile same code on RHL 7.2 and 9.0

    Slavisa, Aug 11, 2003, in forum: C Programming
    Derk Gwen
    Aug 11, 2003
  2. =?ISO-8859-1?Q?Martin_J=F8rgensen?=

    cannot compile the following example code (person-pointer)

    =?ISO-8859-1?Q?Martin_J=F8rgensen?=, Mar 25, 2006, in forum: C++
    Alex Buell
    Mar 31, 2006
  3. Nagaraj
    Lionel B
    Mar 1, 2007
  4. fAnSKyer
    Alf P. Steinbach
    Jun 7, 2009
  5. bluebaron
    Jonathan N. Little
    Nov 4, 2009

Share This Page