Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward Declaration #48

Open
rald opened this issue Oct 20, 2019 · 5 comments
Open

Forward Declaration #48

rald opened this issue Oct 20, 2019 · 5 comments

Comments

@rald
Copy link

rald commented Oct 20, 2019

How can I forward declare a function?

@tch0
Copy link

tch0 commented Aug 25, 2021

You can create a list to save the address of these jump address in code segment that declared but not defined function calls, and function's hash too. Then fill these address after parsing the whole file. Of course, parsing declarations is necessary.

@andrakis
Copy link

Without changes to c4, you cannot forward declare. The changes are not insignificant to make it work.

You could instead try reordering your functions so that they don't need forward declarations.

@tch0
Copy link

tch0 commented Aug 25, 2021

When you call functions mutually, forward declarations will be necessary. What I said is the way to change c4.

@RedContritio
Copy link

Before discussing call mutually, I don't think it's a good design which has interdependency.
You shall make dependence be a chain, but not a ring.

@tch0
Copy link

tch0 commented Aug 25, 2021

Most of the time, we do not need call functions mutually, or you can say it should be avoided. But sometimes, it's inevitable and convenient in some special cases like recursive descent or recursive implementation of AVL tree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants