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

  • Thread starter Christopher M. Lusardi
  • Start date
C

Christopher M. Lusardi

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
 
M

Michael Mair

Christopher said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top