lua-users home
lua-l archive

Re: LuaJIT ignores conflicting typedefs

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


* Mike Pall:
> Florian Weimer wrote:
>> I wonder what the correct semantics would be. Error out on any
>> redeclaration? Or only if the redeclaration differs in a significant
>> way? (Which could boil down to graph isormorphism.)
>
> C99 has strict rules for that. But most compilers use relaxed
> rules.
For duplicate typedefs? Those seem to be allowed in C++. But even in
C++, redeclaration of POD structs is not permitted.
The only extension in this area I'm aware of stems from the lack of
whole-program optimization: You can get away with declaring types
differently in different translation units. But this has never been a
deliberate extension as such.
> For the FFI one would want to use different rules in some places.
> E.g. some users may (wrongly) redeclare intptr_t because they just
> copied the CPP output for the wrong architecture.
My main concern is the lack of an include guard mechanism. For
instance, I may want to declare ssize_t because a C API I want to use
uses that type. But another library tries to declare ssize_t, too.
What should happen in this case?
Responsibility for resolving this conflict could be pushed to library
authors, either through coordination or name mangling. Both
approaches are a bit at odds with the FFI's appeal of simplicity
("just paste the declaration from the manpage into your sources").

AltStyle によって変換されたページ (->オリジナル) /