May 01, 2024, 10:32:02 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Ouch!! Stuck on a C synthax problem , any help ?

Started by pistol350, June 12, 2007, 03:49:21 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pistol350

Does anyone know how to convert this simple line to Aurora ?

s_bitmap * loadbitmap(char *filename, char *packfile);


I may be wrong,
but what i understand is that a pointer "s_bitmap"
is passed to the loadbitmap() function.
But i also think that s_bitmap is the type that must be returned by the function

So to Aurora,
assuming that a char type can easily be replaced by a string type (not really sure though  >:()
we may have :

Declare  loadbitmap(char *filename, char *packfile),s_bitmap;

But if my suggestion is correct, What happened to the pointer that was passed to the function ???

I need a few explanations please  :-\
thanks!
Regards,

Peter B.

Ionic Wind Support Team

Simpler than you think.  A pointer is returned from the function, and two pointers are passed.   In reality two strings are passed.

declare loadbitmap(string filename, string packfile),pointer;

Ionic Wind Support Team

pistol350

June 12, 2007, 07:34:50 AM #2 Last Edit: June 12, 2007, 07:40:42 AM by pistol350
Thank you Paul!

But i am still a bit head ache  ;D since i wonder why in C it is needed to pass the pointers to the strings and to the function,
I mean does the string type have a native pointer while the char type not ? 
(weird question ) :-\



Edit :  Also ,let's say that the declaration was :  s_bitmap loadbitmap(char *filename, char *packfile);

Would it be this in Aurora ? :                           declare loadbitmap(string filename, string packfile),s_bitmap;

I am pretty sure of the answer but ,better searching for light by asking instead of remaining in doubt  ;D
Regards,

Peter B.

Ionic Wind Support Team

C doesn't have a native string type.  It is handled by an array of CHAR and a pointer to that array is used.

Quote
Edit :  Also ,let's say that the declaration was :  s_bitmap loadbitmap(char *filename, char *packfile);

Then you would have to have the definition of the stucture s_bitmap. and it would be:

declare loadbitmap(string filename, string packfile),s_bitmap
Ionic Wind Support Team

pistol350


QuoteThen you would have to have the definition of the stucture s_bitmap. and it would be:

declare loadbitmap(string filename, string packfile),s_bitmap

Yes , it is exacly what i have. :)
Thanks again!

I got One more troublesome line.This one is the kind of very troublesome LOL :

extern int __near joy_init(void);

What i understand is that there is a function which is "joy_init(void)" . ::)
Probably declared to return a data of int type .
But what "the hell" is " __near "  ? :D
A variable , a structure , another type  ???
And finally, what would be an equivalent for Aurora since i don't see anything by myself  :-\
Thanks!
Regards,

Peter B.

Parker

I think you can just leave it out. There's no Aurora equivalent, and I think that __near has to do with what kind of jump statements are emitted by the compiler.

pistol350

Regards,

Peter B.

Ionic Wind Support Team

__near is ignored in most modern C compilers.   It has to to with memory segments and 16 bit code.

Ionic Wind Support Team

pistol350

Regards,

Peter B.