Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
C99 Question
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Clark Cox, post: 1694418"] Pick a language. Either write C or write C++. If you're writing C++, then use new (and don't cast), if you're writing C, then use malloc (and don't cast). If, you are writing C, but trying to feed it to a C++ compiler, then why not just write C++, and be through with it? That is simply wrong. If, for instance, you forget to include stdlib.h, and malloc's prototype is not in scope, a (C89) compiler will assume that malloc is defined as "int malloc()", which means that the result is undefined, and you should get some diagnostic from your compiler. Now, on platforms where sizeof(int) == sizeof(void*), and pointers and integers are returned in the same way, this *might* be fine, but you can't count on it. Casting, in this case, does nothing but hide potential errors. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
C99 Question
Top