The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 (Type *) malloc(sizeof(Type))

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
kid Posted - 07/21/2002 : 5:43:11 PM
What are the restrictions of the OriginC compiler on the malloc function. I've been trying to do a link list using this code
#include <origin.h>

struct spacePoints {
int index;
int xPos;
int yPos;
int zPos;
spacePoints *next;
};

void tryThisOne(void) {

spacePoints start, *node;
start.next = NULL;
node = &start;

for(int count = 0; count < 3; count++) {
node->index = count;
[Line 19] node->next = (spacePoints *) malloc( sizeof(spacePoints) );
node = node->next;
node->next = NULL;
}

printf("The size of this struct is: %d\n", sizeof(spacePoints) );

return;
}

and I get a compiler error on line 19: Error, invalid explicit cast.
Is there a limitation in the OriginC compiler, or is there something wrong in my code. I know I can get around using a link list, by using a wks object, but I'll like to know if Link Lists are sported in OriginC anyway.

Alex...
4   L A T E S T    R E P L I E S    (Newest First)
easwar Posted - 01/12/2006 : 09:10:35 AM
Hi Frank,

This is currently not supported, but will be in the next version.

Easwar
OriginLab


Frank_H Posted - 01/10/2006 : 1:13:33 PM
Is there still no typecast for structs?
Tried

Nag_Spline * spline;
spline = (Nag_Spline *) malloc(sizeof(Nag_Spline));


and got the same error as Alex (Error, invalid explicit cast) :-(

Cheers,
Frank
ML Posted - 12/06/2002 : 11:25:53 AM
quote:

I have got a similar problem. I'm trying to build a working version of
nrutils.c from numerical recipes for Origin C and I get the same error message "Error, invalid explicit cast" in the last line cited here:
 
#define NR_END 1
long nrow=nrh-nrl+1;
float **m;
m=(float**) malloc((size_t) ((nrow+NR_END)*sizeof(float*)));

I'd really be glad if someone could tell me a way round this...


The support for m = (float**)malloc() will be provided in the upcoming service release.
lilo Posted - 12/05/2002 : 09:23:36 AM
I have got a similar problem. I'm trying to build a working version of
nrutils.c from numerical recipes for Origin C and I get the same error message "Error, invalid explicit cast" in the last line cited here:
 
#define NR_END 1
long nrow=nrh-nrl+1;
float **m;
m=(float**) malloc((size_t) ((nrow+NR_END)*sizeof(float*)));

I'd really be glad if someone could tell me a way round this...

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000