|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hi everyone !
Has anyone tried to mix the official POV source code with self-written
C++ code ?
I am using VC5.0 and the compiler does not even recognize the C++
spezific keywords.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Daniel Fenner ha scritto nel messaggio
<36C107FA.E5776109@public.uni-hamburg.de>...
>Hi everyone !
>
>Has anyone tried to mix the official POV source code with self-written
>C++ code ?
>I am using VC5.0 and the compiler does not even recognize the C++
>spezific keywords.
The files have a *.c extension, so the compiler disables C++ syntax. Try to
force C++ compilation: I don't know if there is such an option, you can
anyway rename the files from *.c to *.cpp and try.
Hi
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
>The files have a *.c extension, so the compiler disables C++ syntax. Try to
>force C++ compilation: I don't know if there is such an option, you can
>anyway rename the files from *.c to *.cpp and try.
Also, remember to expose you c interface via extern "c" { <prototypes> }
As an example header, that compiles in both C and C++ for VC5.0:
#ifdef __cplusplus
extern "C"
#endif
///////////////////////////////////////////
//
// C Interface for TarFileSystemDatabase
//
void TF_caseSensitive(int flag);
int TF_addTarFile(const char *filename);
int TF_addTarFiles(const char *directory);
FILE *TF_file(const char *filename,const char *mode);
unsigned long TF_sizeOf(const char *filename);
//
//
/////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Nigel Stewart" <nigels> wrote:
: #ifdef __cplusplus
: extern "C"
: #endif
...
: #ifdef __cplusplus
: }
: #endif
How can this work?
--
main(i){char*_="BdsyFBThhHFBThhHFRz]NFTITQF|DJIFHQhhF";while(i=
*_++)for(;i>1;printf("%s",i-70?i&1?"[]":" ":(i=0,"\n")),i/=2);} /*- Warp. -*/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Nieminen Mika schrieb in Nachricht <36c1ba1d.0@news.povray.org>...
>"Nigel Stewart" <nigels> wrote:
>: #ifdef __cplusplus
>: extern "C"
/* insert: */
{
>: #endif
>
>...
>
>: #ifdef __cplusplus
>: }
>: #endif
>
> How can this work?
Then it will work. I've seen this in *all* (Windows-)API header files I've
ever seen.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hi everybody !
First of all : Thanks for the quick response !
some more questions/remarks concerning POV and C++
1) I guess 'extern "C" {...}' is used to include C headers into C++
files
(correct me if I am wrong)
What I need is the opposite : including a C++ header into a C file.
2) As a work-around I compiled the hole source code as C++. (the option
for VC5.0 is /TP) I'm not completly happy with this. A lot of things
had to be changed (prototypes and typecasts mainly) Furthermore the
linker now produces some unresolved references I can not explain.
I used /FORCE and had luck :->.
Does anyone know a 'nicer' way to solve this problem ?
Thanx
Daniel
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Daniel Fenner wrote:
> Hi everybody !
>
> First of all : Thanks for the quick response !
>
> some more questions/remarks concerning POV and C++
>
> 1) I guess 'extern "C" {...}' is used to include C headers into C++
> files
> (correct me if I am wrong)
> What I need is the opposite : including a C++ header into a C file.
>
> 2) As a work-around I compiled the hole source code as C++. (the option
> for VC5.0 is /TP) I'm not completly happy with this. A lot of things
> had to be changed (prototypes and typecasts mainly) Furthermore the
> linker now produces some unresolved references I can not explain.
> I used /FORCE and had luck :->.
>
> Does anyone know a 'nicer' way to solve this problem ?
Yes.
Valid C code is Valid C++ code.
'extern "C"' will prevent the name mangling.
Therefore, write the accessing of your C++ stuffs in a standard C way, plus
use the extern "C" around its definitions in your header files that are to
be included in the plain C code.
Of course, it is possible that a slight redesign in your code may be needed,
as C has no clue as to how to handle C++ specifics. That is to say, you
might need to create some kind of C compatible wrapper around your C++
objects, depending on how the latter are structured and used.
(I think this is just an elaboration on what Nigel posted earlier)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <36C3426B.32FC9456@public.uni-hamburg.de> , Daniel Fenner
<Dan### [at] publicuni-hamburgde> wrote:
> 1) I guess 'extern "C" {...}' is used to include C headers into C++
> files
> (correct me if I am wrong)
> What I need is the opposite : including a C++ header into a C file.
Some compilers allow to enforce this with a cdecl declaration of a function.
Instead of
void foo();
you would write
void cdecl foo();
However, cdecl is _not_ an ISO C or ISO C++ keyword and might not work with
your compiler.
> 2) As a work-around I compiled the hole source code as C++. (the option
> for VC5.0 is /TP) I'm not completly happy with this. A lot of things
> had to be changed (prototypes and typecasts mainly) Furthermore the
> linker now produces some unresolved references I can not explain.
> I used /FORCE and had luck :->.
Hmm, this is strange. Where were these changes required? In the core code or
in the platform specific code? The core code itself should compile without
error using a C++ compiler...if it does not, it would be very interesting
where VC had problems.
Thorsten
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Thorsten Froehlich wrote:
> Hmm, this is strange. Where were these changes required? In the core code or
> in the platform specific code? The core code itself should compile without
> error using a C++ compiler...if it does not, it would be very interesting
> where VC had problems.
>
Just as an aside, when I built the source using VC 5, I get about 710 warnings.
In my experience this is not the best state to leave code in, so what's the
current status on this? (i.e. is it a known and desired state, just something
that needs time to get to, just something to annoy MS compiler users... :-)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Fri, 12 Feb 1999 00:17:44 -0800, Jon A. Cruz <jon### [at] geocitiescom> wrote:
>Thorsten Froehlich wrote:
>
>> Hmm, this is strange. Where were these changes required? In the core code or
>> in the platform specific code? The core code itself should compile without
>> error using a C++ compiler...if it does not, it would be very interesting
>> where VC had problems.
>>
>
>Just as an aside, when I built the source using VC 5, I get about 710 warnings.
>In my experience this is not the best state to leave code in, so what's the
>current status on this? (i.e. is it a known and desired state, just something
>that needs time to get to, just something to annoy MS compiler users... :-)
You only get 710? :) Most of them are precision warnings, which are really
kind of a nitpicky kind of warning anyway. I've always just ignored them,
until I can find the time to sit down and fix every single one, or someone
else can. There's definitely a lot of float->double->float conversions going
on in various places, but fixing them would be quite a chore.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |