[comp.lang.c++] Including C files into a C++ program

mailhot@IRO.UMontreal.CA (Pierre Mailhot) (05/08/90)

I'm sorry if this topic has already been covered several times before,
but I'm relatively new as regard of C++ and I'm looking for a simple way
to include C program source code into a C++ program.

My problem is as followed: I'm currently using a modified version of the AT&T 
C++ preprocessor which when I include C #include files in a C++ program
doesn't include the #define instructions from these files.

As anybody encountered this problem and/or found a solution to it?

Please e-mail me any answer.
--
Pierre Mailhot
Universite de Montreal, Dep. I.R.O. V-135, C.P. 6128, succursale A 
Montreal (Quebec) H3C 3J7, CANADA, (514) 343-6006, (514) 766-4645
mailhot@iro.umontreal.ca, mailhot@iros1.UUCP

rfg@ics.uci.edu (Ronald Guilmette) (05/08/90)

In article <1990May7.172718.3230@IRO.UMontreal.CA> mailhot@IRO.UMontreal.CA (Pierre Mailhot) writes:
>I'm sorry if this topic has already been covered several times before,
>but I'm relatively new as regard of C++ and I'm looking for a simple way
>to include C program source code into a C++ program.
>
>My problem is as followed: I'm currently using a modified version of the AT&T
>C++ preprocessor which when I include C #include files in a C++ program
>doesn't include the #define instructions from these files.
>
>As anybody encountered this problem and/or found a solution to it?
>
>Please e-mail me any answer.

Sorry.  I'm posting my reply because it may be of general interest.

If you have a (modified & non-standard) preprocessor which is broken,
the solution is to get one which is not modified and/or not broken.

If you include a file, you should get the #defines in that file.

For now, let's assume that you are going to get a non-broken preprocessor.

Now, if you have code (either "base" files or include files) which you need
to run through a C++ translator or compiler, you may (and probably will) need
to make modifications to that code before it will pass cleanly through a
C++ language processor.

Some of the modifications can be made for you via an automated tool that I
have built called protoize.  This tool is freely available.  Send me mail
and I'll tell you how to obtain a copy.

// Ron Guilmette (rfg@ics.uci.edu)
// C++ Entomologist
// Motto:  If it sticks, force it.  If it breaks, it needed replacing anyway.