For Programmers: Free Programming Magazines  


Home > Archive > C > December 2007 > Mix different C source files into a single one









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Mix different C source files into a single one
Horacius ReX

2007-12-29, 6:58 pm

Hi,

I have a C program split into different source files. I am trying a
new compiler and for some reason it only accepts a single source file.
So I need to "mix" all my different C source files into a single one.

Do you know about some program able to do this kind of task ?

Thanks
Malcolm McLean

2007-12-29, 6:58 pm


"Horacius ReX" <horacius.rex@gmail.com> wrote in message
> I have a C program split into different source files. I am trying a
> new compiler and for some reason it only accepts a single source file.
> So I need to "mix" all my different C source files into a single one.
>
> Do you know about some program able to do this kind of task ?
>

I do not believe this for one minute. Try compiling to object files and then
linking by hand.

However, on the offchance that you are correct, set up a file named main.c
which consists of

#include "file1.c"
#include "file2.c"
#include "file3.c"

and invoke the compiler on it. You might have to resolve some static
namespace clashes.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Mark McIntyre

2007-12-29, 6:58 pm

On Sat, 29 Dec 2007 10:03:56 -0800, Horacius ReX wrote:

> Hi,
>
> I have a C program split into different source files. I am trying a new
> compiler and for some reason it only accepts a single source file. So I
> need to "mix" all my different C source files into a single one.


That sounds /very/ unlikely. I suggest you need to read the documentation
again. For example most compilers will accept input along the lines of
cc file1.c file2.c file3.c

> Do you know about some program able to do this kind of task ?


cat, or, if you're windows bound, copy.

Sorting out the resulting mishmash is a job normally left to the
programmer I'm afraid.




Ivan Novick

2007-12-29, 6:59 pm

On Dec 29, 10:03 am, Horacius ReX <horacius....@gmail.com> wrote:
> Hi,
>
> I have a C program split into different source files. I am trying a
> new compiler and for some reason it only accepts a single source file.
> So I need to "mix" all my different C source files into a single one.
>
> Do you know about some program able to do this kind of task ?
>
> Thanks


Which compiler? Which platform?

Regards,
Ivan Novick
http://www.0x4849.net
CBFalconer

2007-12-29, 10:02 pm

Horacius ReX wrote:
>
> I have a C program split into different source files. I am trying a
> new compiler and for some reason it only accepts a single source file.
> So I need to "mix" all my different C source files into a single one.
>
> Do you know about some program able to do this kind of task ?


I think you should dump that 'new compiler' very quickly. If it
can't handle a #include statement, it does not come anywhere near
meeting any standard. I shudder to think what else is missing.

--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee, Frohe Weihnachten
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>



--
Posted via a free Usenet account from http://www.teranews.com

Malcolm McLean

2007-12-30, 3:58 am


"CBFalconer" <cbfalconer@yahoo.com> wrote in message
> I think you should dump that 'new compiler' very quickly. If it
> can't handle a #include statement, it does not come anywhere near
> meeting any standard. I shudder to think what else is missing.
>

Sometimes the compiler is split from the preprocessor. This is permitted,
though a preprocessor should exist.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Thad Smith

2007-12-30, 3:58 am

Horacius ReX wrote:

> I have a C program split into different source files. I am trying a
> new compiler and for some reason it only accepts a single source file.
> So I need to "mix" all my different C source files into a single one.
>
> Do you know about some program able to do this kind of task ?


Are you using the CCS compiler for PIC microcontrollers? That does indeed
want everything compiled together. You can do this by having a main file
#include other code modules.

Note that CCS is pretty far from Standard C. You _can_ mostly program in a
subset of C, but beware the non-standard features of the compiler.

--
Thad
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com