Code Monkey home page Code Monkey logo

Comments (2)

dkl avatar dkl commented on September 3, 2024

Here's a comment that should explain that:

'' In order to avoid adding false-positive forward decls for types like

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.

from fbfrog.

rversteegen avatar rversteegen commented on September 3, 2024

Ah, thanks. There's also another comment here that discusses the issue:

'' TODO: Hard-code some names for commonly used "external" types and then don't

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:

> git diff inc/ | grep "+\s*type.* as " | sed -e 's/+\s*//' | sort | uniq --count | sort -n | tail -n 20
      2 type HWND as HWND_
      2 type iconv_t as iconv_t_
      2 type SOCKET as SOCKET_
      2 type timeval as timeval_
      2 type UBYTE as UBYTE_
      2 type UINT as UINT_
      2 type ULONG as ULONG_
      2 type USHORT as USHORT_
      2 type z_stream as z_stream_
      3 type iovec as iovec_
      3 type LONG as LONG_
      3 type lua_State as lua_State_
      3 type off_t as off_t_
      3 type stat as stat_
      4 type HDC as HDC_
      5 type tm as tm_
      6 type jmp_buf as jmp_buf_
     12 type time_t as time_t_
     22 type va_list as va_list_
     24 type FILE as FILE_

Come to think of it, wouldn't the real solution be to modify fbc to allow

type T as T

type T
	a as integer
end type

Why not?

from fbfrog.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.