Callling C++ code from C

From: Alexei Betin (abetin_at_mail.ru)
Date: 02/11/04


Date: 11 Feb 2004 09:35:43 -0800

C++ FAQ 32.1 (http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html#faq-32.1)
says:
<quote>
- You must use your C++ compiler when compiling main() (e.g., for
static initialization)
</quote>

And what if my C++ library does not have any static objects which
require constructors called (it might define some static C++ object
pointers but initializes them to 0)?

Is there any reason that main() has to be compiled with C++ compiler
besides static initialization? I cannot think of any...

Thanks,
~Alexei



Relevant Pages

  • Re: Callling C++ code from C
    ... >> static initialization) ... I think John is right in that it might work depending on ... compiler - because it does work for me with CC on Solaris. ...
    (comp.lang.cpp)
  • Re: Array initalization doubt.
    ... >> For static objects, yes. ... For automatic objects I would not be so ... The compiler has to generate code to perform the ... does not seem to be the best use of the compiler writers time, ...
    (comp.lang.c)
  • Re: Buffer overflows and asctime()
    ... same way it does for static objects? ... In cases where the compiler can ... example gcc with the right settings says "warning: ... value came from an implicit initialization of an automatic object), ...
    (comp.std.c)
  • Re: Static _Bool initialization
    ... the compiler is in serious trouble. ... assuming the simple model where the compiler concatenates all static objects ... from a translation unit go into one contiguous logical ... points to is the very end of the data segment; if none of the static objects ...
    (comp.std.c)
  • Re: Function call before main.
    ... the compiler might have used the inbuilt ... the main issue you would have to worry about is order of initialization. ... Static objects are initialized in an order that is only partially constrained by the C++ standard; if evaluation of the initializer expression for one object requires retrieval of the value of another static object that hasn't been initialized yet, ... Most compilers treat constraint violations as fatal errors, though all that the standard requires is a diagnostic message, which need not be fatal. ...
    (comp.lang.c)