Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- From: Robby <Robby@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 12 Oct 2008 13:29:00 -0700
Could this be my problem,
mallocs's prototype is:
*int8 malloc(int8 size)
?????
--
Best regards
Robert
"Robby" wrote:
Hello Igor and Scott! Thanks for your much appreciated replies!.
Yes ! I tried the same thing:
*obj_PASSCODE = (PASSCODE*)malloc(sizeof (PASSCODE));
and made all the assigments like so:
(*obj_PASSCODE)->TOUCHES = TOUCHES;
and it works in VC++, but it doesn't work in my MCU compiler, I think it
could be a limitation... I'm not sure, I could be wrong, but in VC++ it works
perfectly, I am able to retrieve the structure's data even in main after its
been set in config(). And the obj_PASSCODE value is reset to 0 after the call
to:
config(e_FREE, &obj_PASSCODE);
Igor, Ilike the idea of doing it with three seperate functions, however if I
have 30 of these configs in my project, this means I will have 90 functions
as opposed to 20. This is my only pet peave. I greatly respect your input, so
what do you think?
So now that I have gotten it to work in the VC++ compiler, I guess the
problem is on my side as to weather its a specific limitaion in my MCU
compiler... mayby my compiler doesn't support pointers to pointers!
Thanks guys, again this post is getting long, so I will let you know what
happens in another post... I sure hope I will eventually get to the bottom of
this!
--
Best regards
Roberto
"Igor Tandetnik" wrote:
"Robby" <Robby@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:213AA21B-76AF-4503-B80F-D0C9307F185B@xxxxxxxxxxxxx
Okay, I have entered the code in VC++ and an error points to the same
line of code:
*obj_PASSCODE = malloc (sizeof (PASSCODE));
The error is:
c:\_DTS_PROGRAMMING\C_PROGRAMMING\c\TEST_4\Test_1.cpp(70): error
C2440: 'type cast' : cannot convert from 'void *' to 'PASSCODE'
malloc() returns void*. Unlike C, there's no implicit conversion in C++
from void* to other pointer types. If you want this code to be valid C++
as well as C, make it
*obj_PASSCODE = (PASSCODE*)malloc(sizeof (PASSCODE));
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
- Follow-Ups:
- Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- From: Barry Schwarz
- Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- References:
- Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- From: Robby
- Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- From: Giovanni Dicanio
- Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- From: Giovanni Dicanio
- Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- From: Robby
- Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- From: Igor Tandetnik
- Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- From: Robby
- Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- Prev by Date: Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- Next by Date: Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- Previous by thread: Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- Next by thread: Re: Seeting malloc pointer to NULL [2] -Totally confused!!!!!
- Index(es):
Relevant Pages
|