Giter VIP home page Giter VIP logo

Comments (3)

dancrossnyc avatar dancrossnyc commented on July 1, 2024

Presumably this is due to, -Werror=lto-type-mismatch, but it's unclear how to address it (at least, unclear to me). p9main here must (unfortunately?) emulate the behavior of main in ignoring its arguments if they are not specified; hence the void p9main(void) formulation. Short of doing a major revision to the source code, this is something that we'll have to figure out how to convince the compiler (or, rather, linker) of being explicitly acceptable.

from plan9port.

eli-schwartz avatar eli-schwartz commented on July 1, 2024

p9main here must (unfortunately?) emulate the behavior of main in ignoring its arguments if they are not specified; hence the void p9main(void) formulation.

Do you mean accepting arguments and then just silently never using their values for any purposes?

from plan9port.

dancrossnyc avatar dancrossnyc commented on July 1, 2024

Not precisely.

In standard C, main is special in that it can be declared several different ways. Notably, int main(int argc, char *argv[]) and int main(void) are both legal; to my knowledge, no other C function is special-cased in the same way (variadic functions are different). The linker must obviously support this as a special case when warning about type mismatches.

The issue with Plan 9 C is that main was declared to return void (that is, have no return value); instead, main is expected to call exits() with a pointer to some status string (or nil, usually just written as 0). For plan9port, p9main is basically a wrapper function that emulates the difference between main in standard and Plan 9 C. However, plan 9 C continued to support the void main(void) vs void main(int argc, char *argv[]) for the benefit of programs that take or do not take command line arguments. But the special case for "real" main doesn't exist for p9main, hence this error.

One wonders if there's a magic flag that would tell the linker, "ignore type mismatches for this particular function." If so, that's the simplest fix.

from plan9port.

Related Issues (20)

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.