Jump to content
IGNORED

Pointers, functions pointers, etc in CC65 for Lynx.


CabaretVoltaire

Recommended Posts

Does CC65 support pointers?

 

I have a line:

 

int (*opcodes[17])(unsigned *);

 

Which works in compilers for other platforms fine but gives me a syntax error in CC65. Also having data types for function arguement returns a syntax error too.

 

Eg:

 

int function(int *variable) or int function(int variable) errors but:

 

function(variable) works

 

 

Am I using an outdated version of the compiler or is it really this limited?

 

Thanks

Link to comment
Share on other sites

Oh, I just read your other message in this base... the version of cc65 you are using is not support by Ullrich von Bassewitz or http://www.cc65.org/ since it is a special port of an old version specifically for lynx development.

 

I also think that it only supports K&R syntax, not ANSI syntax. There are some projects in the works to get a lynx library going for the supported, cross platform CC65 from cc65.org. I started one, but got sidetracked... besides their are smarter men than me working on it already.

 

HTH.

Link to comment
Share on other sites

I've messed around with it a bit and looked through some of the examples to get a feel of the syntax and have got around the problem:

 

//create a function

int return_a_number(number)

int number;

{

return number;

}

 

//create an array of function pointers

int (*func_ptr[1])(number);

 

 

//set a pointer like:

func_ptr[0] = (int (*)())return_a_number;

 

//call the function like:

an_integer = (*func_ptr[0])(5);

 

 

Seems to work fine :)

 

Thanks for your help :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...