POV-Ray : Newsgroups : povray.programming : C vs. C++ Server Time
28 Jul 2024 18:16:32 EDT (-0400)
  C vs. C++ (Message 1 to 6 of 6)  
From: Ken
Subject: C vs. C++
Date: 29 Jun 1999 16:28:52
Message: <37792C41.D71285EF@pacbell.net>
I know that the windows version of 3.1 has been compiled using
msvc6 a C++ compiler. Pov has traditionaly been written in C. Has
the code all been changed to C++ or does the current windows version
only have the distinction of being a program written in C and compiled
with a C++ compiler ?

Does any of that make any sense ?


-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

From: Ron Parker
Subject: Re: C vs. C++
Date: 29 Jun 1999 17:45:15
Message: <37793e6b@news.povray.org>
On Tue, 29 Jun 1999 13:27:45 -0700, Ken wrote:
> I know that the windows version of 3.1 has been compiled using
>msvc6 a C++ compiler. Pov has traditionaly been written in C. Has
>the code all been changed to C++ or does the current windows version
>only have the distinction of being a program written in C and compiled
>with a C++ compiler ?

It's still written in C.  VC6, like most C++ compilers, is quite capable
of falling back on a C grammar when confronted with C source, and that is
exactly what it does.  So what you have is a C program compiled with a
C compiler.


Post a reply to this message

From: Dick Balaska
Subject: Re: C vs. C++
Date: 30 Jun 1999 03:59:37
Message: <3779CE4A.3DB929C8@buckosoft.com>
Ron Parker wrote:
> 
> On Tue, 29 Jun 1999 13:27:45 -0700, Ken wrote:
> > I know that the windows version of 3.1 has been compiled using
> >msvc6 a C++ compiler. Pov has traditionaly been written in C. Has
> >the code all been changed to C++ or does the current windows version
> >only have the distinction of being a program written in C and compiled
> >with a C++ compiler ?
> 
> It's still written in C.  VC6, like most C++ compilers, is quite capable
> of falling back on a C grammar when confronted with C source, and that is
> exactly what it does.  So what you have is a C program compiled with a
> C compiler.

Actually, they are different compilers.  If you have a file foo.c, it will
use the C compiler. foo.cpp (or foo.cxx) uses the c++ compiler.
The M$ C compiler has been stable for several years and generates descent
code.  The C++ compiler is fairly buggy.  You can get different bugs
by tweaking the optimizations.  Neither devstudio/VC++6 service pack
addressed a single compiler/code generation bug. (Mostly dll tweaks so 
you can play on the same machine as Office2000/IE5)

dik


Post a reply to this message

From: Nieminen Mika
Subject: Re: C vs. C++
Date: 30 Jun 1999 06:30:06
Message: <3779f1ae@news.povray.org>
This is true. Moreover, if you want to call a C-function from C++-code,
you have to declare the function as: extern "C" foo bar(); (because the
internal naming convention is different for C and C++).

  Btw, how do I call a C++ function from C?

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Ron Parker
Subject: Re: C vs. C++
Date: 30 Jun 1999 10:26:36
Message: <377a291c@news.povray.org>
On Wed, 30 Jun 1999 03:59:06 -0400, Dick Balaska wrote:
>Ron Parker wrote:
>> 
>> On Tue, 29 Jun 1999 13:27:45 -0700, Ken wrote:
>> > I know that the windows version of 3.1 has been compiled using
>> >msvc6 a C++ compiler. Pov has traditionaly been written in C. Has
>> >the code all been changed to C++ or does the current windows version
>> >only have the distinction of being a program written in C and compiled
>> >with a C++ compiler ?
>> 
>> It's still written in C.  VC6, like most C++ compilers, is quite capable
>> of falling back on a C grammar when confronted with C source, and that is
>> exactly what it does.  So what you have is a C program compiled with a
>> C compiler.
>
>Actually, they are different compilers.  If you have a file foo.c, it will
>use the C compiler. foo.cpp (or foo.cxx) uses the c++ compiler.

They're the same executable.  Go to a command prompt and type cl /? and 
you'll get, among other things, this:

/Tc<source file> compile file as .c
/Tp<source file> compile file as .cpp
/TC compile all files as .c
/TP compile all files as .cpp

>The M$ C compiler has been stable for several years and generates descent
>code.  The C++ compiler is fairly buggy.  You can get different bugs
>by tweaking the optimizations.  Neither devstudio/VC++6 service pack
>addressed a single compiler/code generation bug. (Mostly dll tweaks so 
>you can play on the same machine as Office2000/IE5)

The C compiler has only been stable for "several years" if your definition 
of the term allows for the interpretation "a little over a year."  Everyone 
here remembers how VC5 (without the service packs) couldn't compile 
lighting.c with global optimizations turned on because cl would get stuck 
in an infinite loop.

Reading the readme that comes with VC6 SP3 tells me the following issues 
that were fixed and were compiler/optimizer/linker bugs:

Q187280  Q192539  Q194615  Q195376  Q199736  Q205681  Q216181  Q216720
Q216727  Q216715  Q216716  Q216718  Q216722  Q216731  Q216747  Q216854
Q217033  Q195377  Q217171  Q217168  Q217164  Q217755  Q218611  Q218613

And that's just the bugs fixed between SP2 and SP3.  There are similar
lists for the other service packs, but I no longer have them at hand.


Post a reply to this message

From: Ron Parker
Subject: Re: C vs. C++
Date: 30 Jun 1999 10:36:37
Message: <377a2b75@news.povray.org>
On 30 Jun 1999 06:30:06 -0400, Nieminen Mika wrote:
>  This is true. Moreover, if you want to call a C-function from C++-code,
>you have to declare the function as: extern "C" foo bar(); (because the
>internal naming convention is different for C and C++).
>
>  Btw, how do I call a C++ function from C?

Assuming you mean a global or static method that doesn't take reference 
or class parameters, which is to say one that you can actually call from C, 
just mark the prototypes as extern "C":

#ifdef __cplusplus
  extern "C" {
#endif
    int myfunc1( int, char );
    .
    .
    .
#ifdef __cplusplus
  }
#endif

You may have to write stubs to call static methods.

If you can't change the C++ code, you're still okay.  You can write a C++
wrapper that consists entirely of stub "C" functions that call the name-
mangled C++ versions.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.