On 2011-08-02, arnuld <> wrote:
>> On Tue, 26 Jul 2011 18:42:11 +0000, Seebs wrote:
>> Compile C code in C. Don't compile C code in other languages. If you
>> need to mix C and other languages, do it by separating C and other
>> languages into separate hunks of code. Compile C with the C compiler,
>> which does not need casts for malloc. If you need to call C from
>> another language, do so by using whatever tools that language has for
>> calling C.
> I have seen industrial programmers doing casts and saying that it will
> need to be compiled by C++ compiler. Many times I have seen this casting
> being done in projects where both C and C++ code is being used.
I have seen that too.
> Is this a
> wrong practice to cast when code has to be compiled by C++ compiler.
No. The wrong practice is to set things up so that C code has to be
compiled by a C++ compiler.
> And
> I don't see how can you call C from C++ (may be I am less experienced) ?
Usually, it's very simple: Declare something as extern "C", and then
compile it as C in a separate module, and then... just call it. This
was intentionally made easy, which is why I think that code which "has to
be compiled as C++ too" is almost always a mistaken concept.
-s
--
Copyright 2011, all wrongs reversed. Peter Seebach /
usenet-
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.