Pointer initialization and usage.
  Home FAQ Contact Sign in
comp.lang.c.moderated only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.c.moderated Profile…
 Up
Pointer initialization and usage.         


Author: Vickynathan
Date: May 8, 2008 00:20

The following code snippet works. I wonder how ? ( this is a code for
microcontroller )

void main (void){

unsigned char xdata * data pwrite;
unsigned char code * data pread;
unsigned char test_array [16];
unsigned char temp;
....
....
....

pwrite = (unsigned char xdata *) Scratch_Flash_Addr ; // I have
never seen such an initialization ??
pread = my_array ;

.....
.....
Show full article (0.88Kb)
7 Comments
Re: Pointer initialization and usage.         


Author: Francis Glassborow
Date: May 9, 2008 15:33

Vickynathan wrote:
> The following code snippet works. I wonder how ? ( this is a code for
> microcontroller )

By saying it works, I guess you mean it compiles, however if it is for a
microcontroller I wonder if you are using a compiler that specifically
targets that hardware. Many compilers for microcontrollers include
hardware specific extensions.
>
> void main (void){
So the above line suggests that you are not using a standard conforming
implementation. At a guess you are using an extended implementation for
a free-standing system.
Show full article (2.04Kb)
no comments
Re: Pointer initialization and usage.         


Author: Kenneth Brody
Date: May 9, 2008 15:33

Vickynathan wrote:
>
> The following code snippet works. I wonder how ? ( this is a code for
> microcontroller )
>
> void main (void){
>
> unsigned char xdata * data pwrite;
> unsigned char code * data pread;
> unsigned char test_array [16];
> unsigned char temp;
> ....
> ....
> ....
>
> pwrite = (unsigned char xdata *) Scratch_Flash_Addr ; // I have
> never seen such an initialization ??
Show full article (1.95Kb)
no comments
Re: Pointer initialization and usage.         


Author: Hans-Bernhard Bröker
Date: May 9, 2008 15:33

Vickynathan wrote:
> The following code snippet works. I wonder how ?

It works by its author having read the applicable documents (a C
textbook, and the particular compiler's documentation) and learning from
them. I suggest you try that, too.
> pwrite = (unsigned char xdata *) Scratch_Flash_Addr ; // I have
> never seen such an initialization ??

There's nothing magical about it. See the C textbook on what (unsigned
char *) would mean, and the compiler documentation on the meaning of
'xdata'. See the rest of the source code to understand where
Scratch_Flash_Addr might be coming from.
> temp = pread[i]; // How is this possible
> without an indirection operator ?

By reading the C textbook.
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
no comments
Re: Pointer initialization and usage.         


Author: Jack Klein
Date: May 9, 2008 15:33

On Thu, 8 May 2008 02:20:26 -0500 (CDT), Vickynathan
hotmail.com> wrote in comp.lang.c.moderated:
> The following code snippet works. I wonder how ? ( this is a code for
> microcontroller )
>
> void main (void){

Before anyone else mentions it, since this is a free-standing
implementation, void main() is not necessarily undefined behavior, and
in fact is this particular implementation's normal entry point. In
small embedded systems, there is nothing for main() to return to.
> unsigned char xdata * data pwrite;
> unsigned char code * data pread;

You realize, I hope, that the non-standard extra keywords "xdata",
"data", and "code" are specific to your compiler. As it happens,
they have no real impact on your question.
Show full article (2.97Kb)
no comments
Re: Pointer initialization and usage.         


Author: Vickynathan
Date: May 12, 2008 23:06

On May 10, 3:33 am, Kenneth Brody spamcop.net> wrote:
> Vickynathan wrote:
>
>> The following code snippet works. I wonder how ? ( this is a code for
>> microcontroller )
>
>> void main (void){
>
>> unsigned char xdata * data pwrite;
>> unsigned char code *  data pread;
>> unsigned char test_array [16];
>> unsigned char temp;
>> ....
>> ....
>> ....
>
>> pwrite = (unsigned char xdata *) Scratch_Flash_Addr ;    // I have
>> never seen such an initialization ??
>
> You don't show the definition for Scratch_Flash_Addr, but given ...
Show full article (2.99Kb)
no comments
Re: Pointer initialization and usage.         


Author: Vickynathan
Date: May 12, 2008 23:06

On May 10, 3:33 am, Jack Klein spamcop.net> wrote:
> On Thu, 8 May 2008 02:20:26 -0500 (CDT), Vickynathan
> hotmail.com> wrote in comp.lang.c.moderated:
>
>> The following code snippet works. I wonder how ? ( this is a code for
>> microcontroller )
>
>> void main (void){
>
> Before anyone else mentions it, since this is a free-standing
> implementation, void main() is not necessarily undefined behavior, and
> in fact is this particular implementation's normal entry point.  In
> small embedded systems, there is nothing for main() to return to.
>
>> unsigned char xdata * data pwrite;
>> unsigned char code *  data pread;
>
> You realize, I hope, that the non-standard extra keywords "xdata",
> "data",  and "code" are specific to your compiler.  As it happens,
> they have no real impact on your question. ...
Show full article (3.65Kb)
no comments
Re: Pointer initialization and usage.         


Author: Francis Glassborow
Date: May 12, 2008 23:06

Jack Klein wrote:
> On Thu, 8 May 2008 02:20:26 -0500 (CDT), Vickynathan
> hotmail.com> wrote in comp.lang.c.moderated:
>
>> The following code snippet works. I wonder how ? ( this is a code for
>> microcontroller )
>>
>> void main (void){
>
> Before anyone else mentions it, since this is a free-standing
> implementation, void main() is not necessarily undefined behavior, and
> in fact is this particular implementation's normal entry point. In
> small embedded systems, there is nothing for main() to return to.
Yes, true and easy to miss.

Show full article (1.54Kb)
no comments