lua-users home
lua-l archive

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

On Wed, Nov 21, 2018 at 8:27 AM Dirk Laurie <> wrote:

> The point of the exercise is simply that patching can be avoided by this trick, for which I claim no originality.

The point of my message is that the exercise violates the rules of the C language and is inherently dangerous. It would be a disservice to the community to promote your method without this clearly stated.

> Admittedly I do not have the C11 standard open in front of me (which BTW seems to be totally irrelevant when a program is compiled according to the gnu99 standard)

You did say:

[...] pleading that a better (not Linux-specfic, and also saying how to do it for liblua.a or liblua.dll as the case may be) description than mine might in future be described there.  


In that broader context your method ought to be supported by a language standard rather than a particular tool. Even with that tool, though, your method is dangerous.

The requirement that names with external linkage shall be defined at most once is not new in C11. It existed already in C89, viz., clause 3.7:

If an identifier declared with external linkage is used in an _expression_ (other than as part of the operand of a sizeof operator), somewhere in the entire program there shall be exactly one external definition for the identifier.


Observe how the more recent standard is almost a verbatim replica of the old one in this respect. This is not accidental, because the requirement of _one_ definition of an external entity is a basic tenet of C and is traceable back K&R 's book (1978). Your method is fundamentally flawed.