Why is not more FreeBSD software written in C++?

Don Dugger dugger at hotlz.com
Sat Apr 22 19:18:38 UTC 2006


Dag-Erling Smørgrav wrote:

>Don Dugger <dugger at hotlz.com> writes:
>  
>
>>Dag-Erling Smørgrav <des at des.no> writes:
>>    
>>
>>>Don Dugger <dugger at hotlz.com> writes:
>>>      
>>>
>>>>The fact is that all your c code will compile in c++
>>>>        
>>>>
>>>That is wrong.  To name just one example, C++ is much stricter about
>>>type casts than C is.
>>>      
>>>
>>I mean the constructs. Casting will not change the functionality or
>>shouldn't.
>>    
>>
>
>It does.  Casting can be (and often is) used to force or avoid sign
>promotion in function arguments; for instance, isspace(ch) may produce
>incorrect results if ch is a char, so a cast to int is required.
>
>C allows any expression of pointer type to be assigned to a void *,
>and allows any expression of type void * to be assigned to any object
>pointer type.  C++ does not.  As a result, a typical C program which
>uses malloc() without casting the result will not compile cleanly with
>a C++ compiler.  A competent C programmer will balk at adding the cast
>that C++ requires; a competent C++ programmer will correctly point out
>that a C++ program should not use malloc() anyway.
>
>There are other incompatiblities: const has different semantics in C
>and C++, namespaces aren't quite the same (there is no separation
>between the typedef namespace and the struct namespace in C++), etc.
>
>DES
>  
>
And how does that change my point?

Don 8)


More information about the freebsd-chat mailing list