Re: [cc65] c programm

Date view Thread view Subject view

From: sandree (vorsichtphysiker_at_gmx.net)
Date: 2003-02-05 21:58:24


sorry for speaking slang german!!!


ok, but do i need a variable with this type? i think, that the compiler just
needs to know how to pass a variable with that type. and if i declare a
prototype of the function setcharcolors with the type as argument, the
compiler should know what to do with the variables i pass.

>> typedef struct{
>> char color1, color2;
>> } ROYWINCOL_T;
> 
> This defines a type but doesn't reserve any space for the struct. Add
> 
> ROYWINCOL_T a;
> 
> to actually have a variable named "a" of that type.
> 

why is the implementation not defined ? i declared the type before?

>> void  setcharcolors(ROYWINCOL_T colors);
> 
> Here you declare a function 'setcharcolors' which takes a ROYWINCOL_T
> struct as argument, but it's implementation isn't defined. What should
> happen if you call this function?
> 
>> void main(void){
>> setcharcolors({1,0});
>> }
> 

sure it can tell, using the prototype!

> A compiler doesn't know what to do with "{1,0}". You/it can't tell what
> type it is. It compiles with gcc if you cast it to ROYWINCOL_T:
> setcharcolors((ROYWINCOL_T){1,0});
> 
> It doesn't work in cc65. Maybe because that's a non standard way of
> using anonymous structs (correct term?) but I remember vaguely that
> cc65 can't pass structs as function parameters. So maybe you want to
> rewrite it this way:
> 
> typedef struct{
> char color1, color2;
> } ROYWINCOL_T;
> 
> ROYWINCOL_T a;
> 

ok, that would be a way, but i likeley want to pass the parameters in
__fastcall__ style. but only the rightmost parameter is passed as
registers(a,x). thats why i combined c1 and c2 in a struct.

> void  setcharcolors(char c1, char c2) {
> a.color1 = c1;
> a.color2 = c2;
> }
> 
> void main(void){
> setcharcolors(1,0);
> } 
> 
> Ciao,
> Marc 'BlackJack' Rintsch

thank you !

carlos

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-02-05 23:01:10 CET