-
Notifications
You must be signed in to change notification settings - Fork 17
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
Automatic forward declarations? #4
Comments
Here's a comment that should explain that: Line 3011 in f0ec0de
But if it's more annoying than useful, then it's the wrong default. It would be interesting to run all of fbbindings with the opposite default and without the -addforwarddecl options, to see how many -noforwarddecl options would be needed. |
Ah, thanks. There's also another comment here that discusses the issue: Line 1453 in f0ec0de
Since FILE, etc, in standard headers are the main reason for this behaviour I think you could say the problem is that fbfrog doesn't know what's in them. If we added minimal include/fbfrog/stdio.h, etc headers which only declared common structs then there may be minimal need for -noforwarddecl. I would also argue that -fbfroginclude for standard headers could be the default: translating system headers is a special case for which automatic inclusion could be disabled (-nofbfrogincludes), and likely no end user is ever going to be doing so. I'm currently testing it in fbbindings. It's 263 -addforwarddecl's that can all be removed, and it also reveals more that are missing from various headers. There are about 204 forward declarations introduced (109 unique ones), the majority of which are common ones from crt/posix, winapi or opengl although most occur only 1-2 times:
Come to think of it, wouldn't the real solution be to modify fbc to allow
Why not? |
Currently, fbfrog ignores forward struct declarations by default, if no definition of the struct appears later:
translates to
whereas if
struct Typ {int a;};
appears later you getWithout the definition, adding
-addforwarddecl Type
is necessary to get a working translation.Why not add a forward declaration automatically if there is a C declaration but no definition; is it not desirable for some reason, or is it simply not implemented? The only reason to avoid doing so that I can think of is if there's another header that fbfrog wasn't given which will have already defined it. But that would be the exception, not the norm, accommodated with a
-noforwarddecl
option.The text was updated successfully, but these errors were encountered: