linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: kaushal <kaushal@rocsys.com>
To: _z33 <timid.Gentoo@gmail.com>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: typecasting - explain
Date: Fri, 09 Sep 2005 13:03:15 +0530	[thread overview]
Message-ID: <1126251195.4506.81.camel@kaushal> (raw)
In-Reply-To: <dfrckc$ts5$1@sea.gmane.org>

hi _z33,
        Someone correct me if Iam wrong.the idea behind typecasting is
to tell the compiler how u want to access a particular region in
memory.Whether the region has to considered in terms of 4bytes at a time
or interms of 1 byte at a time or 2bytes so on.ie.. when you use a
variable to access a memory region the datatype of the variable would
tell the size of the memory region which has meaningful data for us.
When u typecast a variable it means u r trying to increase or decrease
the memory region size.Compiler simply helps you do that.It will not
bother if you are trying to use the data at that memory location is used
as an address or data.Its how we use it.

cheers-
kaushal.
On Fri, 2005-09-09 at 12:46 -0700, _z33 wrote:
>    I'm not able to understand what exactly happens when I typecast a 
> data type from one to other. What I had in mind was, that by typecasting 
> you are making it clear to the compiler how to handle the data. For 
> example, when you get a "void *" from malloc, the reason you typecast it 
> to the required data type, is to make sure later the compiler doesn't 
> complain or throw an error, when doing some pointer arithmetic on it. Am 
> I wrong completely?
>    If my conception is correct, then I'm having a serious problem in 
> understanding typecasting of function pointers. First of all, I thought 
> it is meaningless and the compiler won't allow it. However, to my shock 
> I came across a posting today morning on a different newsgroup, claiming 
> that it is in fact supported by the ANSI standard. Is it? If so, what 
> does such a typecasting mean?
> 
> _z33


  reply	other threads:[~2005-09-09  7:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-09 19:46 typecasting - explain _z33
2005-09-09  7:33 ` kaushal [this message]
2005-09-09  8:48   ` _z33
2005-09-09  9:28     ` Jarmo
2005-09-09 10:04       ` _z33
2005-09-09 13:19         ` Glynn Clements
2005-09-09  9:46 ` Steve Graegert
2005-09-09 10:22   ` _z33
2005-09-09 10:49     ` Steve Graegert
2005-09-09 11:10       ` _z33
2005-09-09 11:29         ` Steve Graegert
2005-09-09 13:17 ` Glynn Clements

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=1126251195.4506.81.camel@kaushal \
    --to=kaushal@rocsys.com \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=timid.Gentoo@gmail.com \
    /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 NNTP newsgroup(s).