Git Product home page Git Product logo

Comments (5)

rossberg avatar rossberg commented on June 23, 2024

Hm, interesting, but the way I read it is that the restrictions stated there constrain implementations of POSIX and what implementation-specific symbols they can add to POSIX header files. AFAICS they do not constrain third-party libraries with independent header files.

For the Wasm API, all C names have consciously been given a wasm_ prefix, so I expect the potential for conflict to be minimal to non-existent.

from wasm-c-api.

wahern avatar wahern commented on June 23, 2024

The suffix is reserved for all POSIX and C headers. (Note the [CX], which means it's extending the C standard, which means its reserving for C headers as well.) If your code never includes a header like <stdlib.h>, then you're good. I've written C source file that didn't include any C or POSIX header. But if your code includes such a header and also defines identifiers (directly or indirectly) with the _t suffix, then there's potential for namespace clash, especially if you're defining them in headers to be used by other applications.

In practice few people know this, let alone obey it. But I figured standards should probably be neighborly.

from wasm-c-api.

rossberg avatar rossberg commented on June 23, 2024

Sigh, modularity and name spacing are such a sad story in C.

The only unqualified type names we define are the byte_t, float32_t, and float64_t synonyms. I agree that we should probably avoid those. (It's unfortunate that they do not exist in any standard header.)

For everything else I don't know. We indeed include some C headers. However, as mentioned, all our names are sanitised with wasm_ prefixes. If POSIX makes such a sweeping land grab in the C name space that it even prevents harmless uses like that -- and generally is in conflict with large parts of dev reality -- then I don't know if third parties should feel obliged to obey to the letter. And I'm saying that as a person who usually very much prefers conforming to standards

from wasm-c-api.

wahern avatar wahern commented on June 23, 2024

FWIW, the use of _t in the API doesn't really add anything. For years, before I read and understood the standards, I thought _t was an idiom for scalar typedefs (integers, pointers) or more generally (in my rationalizations) POD types that could be copied by simple assignment, and that's how I always used it. IME most software that uses _t rarely uses it for aggregate objects like structs or unions. What originally clued me into the issue was how the pthreads API uses _t for aggregate objects, including ones that couldn't be copied, which seemed irregular until I learned that the whole point of _t was for namespacing, not readability.

That said, I only wanted to bring the issue to your attention. I don't care to bikeshed style. Feel free to dispose of this issue however you want ;)

from wasm-c-api.

rossberg avatar rossberg commented on June 23, 2024

Actually, the main benefit of the convention from my perspective is that you don't get into syntactic issues where you want to name a variable or function after a type, because C syntax does not properly separate the name spaces.

Anyway, thanks for bringing this up. I at least want to reconsider the use of unqualified type names.

from wasm-c-api.

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.