Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-dev] Mixed C/C++ in MBS

leo> Let's see if we can turn this into specific proposal.  I'm not an 
leo> expert in the pitfalls of mixed C/C++, so here are some questions:

Good idea, I'll try to answer them from our perspective.

leo> 1.  Do you always want to compile source with C extensions 
leo> with the C compiler and sources with C++ extensions with 
leo> the C++ compiler?

Yes.

The other issue is the CFLAGS, it is more of a usablity issue.

At franklin C/C++, we use this nomenclature in our Makefiles

        CPP_ONLY_CFLAGS=
        C_ONLY_CFLAGS=
        COMMON_CFLAGS=

Without COMMON, you duplicate the -Ddefine and -Iinclude flags
sometimes you miss them, or the list becomes huge.

Likewise, we have these for S files.

        S_ONLY_FLAGS=   [note: upper case S]
        s_ONLY_FLAGS=   [note: lower case s]
        sS_COMMON_FLAGS [note: mixed case sS]

Perhaps other mixes have the same issue [ie: Fortran/Java, etc]

Perhaps the really tough issue will be the person extending Java
with C or C++, not uncommon, for example we extend Tcl/Tk often.
In my mind that level of a mix is "way down the road".

NOTE:
        The ARM people perhaps would want to speak up about the 
        seperate ARM-CC and THUMB-CC permutations.

leo> 2.  What about the linker to use?  With mixed C/C++ is it 
leo> always the C++ linker?

To answer your question directly: Yes, any C++ means the C++ Linker.

My view is this: The PROJECT TYPE declares the linker type to use.

> 4.  What about Pete's scenario below?  If the user has only C sources
> and selects a C project, but is using one or more C++ libraries, will
> the C linker work?  If not, what can we do about this case?

Will the linker work? It depends on how the static constructors are 
handled. You learn quickly if you have made this mistake.

In my view, the user has selected wrong. They actually have a mixed
C/C++ project, and should have created a C++ project that has no C++ 
files.

-Duane.




Back to the top