How To Reduce Number Files by Putting file1.c and file2.C Together

Discussion in 'C Programming' started by Christopher M. Lusardi, Nov 16, 2004.

  1. Hello,

    I have a program that can be compiled and run on SGI and Linux computers,
    and only one of the files in the program has is different. On the SGI
    system, the file has a dot capital C suffix, and on Linux it has a dot
    lower case c suffix.

    When I put both files in one file and surround them with precompiler
    directives such as #if SGI ... #elif LINUX ... #endif, the compiler
    complains when it includes other files. How can I get it to compile
    and run on both computers?

    Thank you,
    Christopher M. Lusardi
     
    Christopher M. Lusardi, Nov 16, 2004
    #1
    1. Advertising

  2. Christopher M. Lusardi

    Michael Mair Guest

    Christopher M. Lusardi wrote:
    > Hello,
    >
    > I have a program that can be compiled and run on SGI and Linux computers,
    > and only one of the files in the program has is different. On the SGI
    > system, the file has a dot capital C suffix, and on Linux it has a dot
    > lower case c suffix.


    Note that usually the latter denotes a C source file and the former
    usually not. If this is not the case, you can use your approach
    to put them together.
    Otherwise, you at least have to change the makefiles for your project
    if there are some or the way you build everything.

    > When I put both files in one file and surround them with precompiler
    > directives such as #if SGI ... #elif LINUX ... #endif, the compiler
    > complains when it includes other files. How can I get it to compile
    > and run on both computers?


    Try
    #if defined SGI
    .....
    #elif defined LINUX
    .....
    #endif
    if anything.

    C and C++ are different languages and it is a Bad Idea to splice
    the files together if they are in different languages.

    If they are in the same language and are not completely different
    (look, e.g. at "diff -u file.c file.C |less") then treat only
    the different places differently with the help of conditional
    compilation.
    However, it is probably the best if you leave the whole thing
    alone if you do not understand the issues involved.


    -Michael
    --
    E-Mail: Mine is a gmx dot de address.
     
    Michael Mair, Nov 16, 2004
    #2
    1. Advertising

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. Alex Pet
    Replies:
    0
    Views:
    1,402
    Alex Pet
    Jan 20, 2004
  2. Replies:
    4
    Views:
    479
  3. Saurabh
    Replies:
    6
    Views:
    4,596
    Chris Smith
    May 30, 2004
  4. Christopher M. Lusardi
    Replies:
    1
    Views:
    363
    Michael Mair
    Nov 16, 2004
  5. how to do file1-file2?

    , Mar 13, 2007, in forum: Perl Misc
    Replies:
    2
    Views:
    116
    Tad McClellan
    Mar 13, 2007
Loading...

Share This Page