public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Harri Järvi" <harri.jarvi@ajatus.org>
To: Christian Schoenebeck <cuse@users.sourceforge.net>
Cc: gcc-help@gcc.gnu.org, Andrew Haley <aph@gcc.gnu.org>,
		linuxsampler-devel@lists.sourceforge.net
Subject: Re: [Linuxsampler-devel] Re: GCC Vector Extensions
Date: Wed, 19 Apr 2006 14:58:00 -0000	[thread overview]
Message-ID: <20060419145843.GA13273@novelli> (raw)
In-Reply-To: <200604191440.05820.cuse@users.sourceforge.net>

On Wed, Apr 19, 2006 at 14:40:01 +0200, Christian Schoenebeck wrote:
> int main() {
>     const v4sf v = { 1.2f ,2.2f ,3.3f, 4.4f };
>     printf("v4sf v = { %f, %f, %f, %f }\n", ((float*)&v)[0],((float*)&v)[1],((float*)&v)[2],((float*)&v)[3]);
>     const v4i vRes = (v4i) v;
>     printf("v4i vRes = { %d, %d, %d, %d }\n", ((int*)&vRes)[0],((int*)&vRes)[1],((int*)&vRes)[2],((int*)&vRes)[3]);
> }

Shouldn't one use c++-style casts instead. static_cast<type>() is the 
one I think would be the one to use here. C-style casts are ambigous and 
most of the time its difficult or impossible to know what they should 
do.

This is the case because there is only one notation for all different 
type casts in C. In C++ you can use different type cast for different 
things.

See http://www.cplusplus.com/doc/tutorial/typecasting.html
for all 4 type casts in C++.

-Harri

  parent reply	other threads:[~2006-04-19 14:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-07 19:03 Christian Schoenebeck
2006-04-07 20:16 ` Greg Buchholz
2006-04-15  0:58   ` Christian Schoenebeck
2006-04-18 10:04     ` Andrew Haley
2006-04-18 23:38       ` Christian Schoenebeck
2006-04-19  8:30         ` Andrew Haley
2006-04-19 12:19           ` Christian Schoenebeck
2006-04-19 13:13             ` John Love-Jensen
2006-04-19 14:03             ` Andrew Haley
2006-04-19 15:20               ` Andrew Haley
2006-04-19 20:05                 ` Christian Schoenebeck
2006-04-19 20:25                   ` Andrew Haley
2006-04-19 14:58             ` Harri Järvi [this message]
2006-04-19 15:14               ` [Linuxsampler-devel] " Brian Budge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060419145843.GA13273@novelli \
    --to=harri.jarvi@ajatus.org \
    --cc=aph@gcc.gnu.org \
    --cc=cuse@users.sourceforge.net \
    --cc=gcc-help@gcc.gnu.org \
    --cc=linuxsampler-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).