On Fri, Jul 8, 2016 at 4:56 PM, Daniel Seither <p...@tiwoc.de> wrote:
> Using clang 3.8 with -Wreserved-id-macro (enabled by -Weverything), I > just noticed that SQLite uses include guards with a leading underscore, > for example _SQLITE3_H_ in the amalgamation. According to the C > standard, this is a reserved identifier, leading to undefined behavior: > > > All identifiers that begin with an underscore and either an uppercase > > letter or another underscore are always reserved for any use. [...] > > If the program declares or defines an identifier in a context in > > which it is reserved (other than as allowed by 7.1.4), or defines a > > reserved identifier as a macro name, the behavior is undefined. > > sqlite isn't a program :) it's a library. > (Source: the C11 standard, Section 7.1.3, see [1] for the latest draft > of C11 before publication, which should be identical to the finished text) > > I guess that means that the include guards should be changed to no > longer use leading underscores. Any opinions on that? > > That has been in the standard since K&R. http://stackoverflow.com/questions/22027252/what-define-identifiers-are-reserved-to-the-preprocessor " (C99, 7.1.3.p1) "All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use." Now regarding K&R book 2nd edition it is written: (K&R 2nd edition, 2.1) "Don't begin variable names with underscore, however, since library routines often use such names." And if CRM actually refers to CARM (C A Reference Manual by Harbison & Steele): (CARM 5th edition, 10.1.1 Reserved Library Identifiers): "The identifiers that are reserved for C implementations to use include: [...] for macros, keywords, or global variables, identifiers beginning with _ and and either a second _ or an uppercase letter (except _ _ STDC_...)" http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier could make it _sQLITE3_H > Daniel > > [1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users