Frama-C-discuss mailing list archives
This page gathers the archives of the old Frama-C-discuss archives, that was hosted by Inria's gforge before its demise at the end of 2020. To search for mails newer than September 2020, please visit the page of the new mailing list on Renater.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Frama-c-discuss] Printing all global variables of a set of C files?
- Subject: [Frama-c-discuss] Printing all global variables of a set of C files?
- From: pascal.cuoq at gmail.com (Pascal Cuoq)
- Date: Mon, 30 Sep 2013 18:32:39 +0200
- In-reply-to: <CA+yPOViM5uojsLY10UTC1RMDb5fCQVcoPMirmh1+eJ7AmMcOLQ@mail.gmail.com>
- References: <CAC3Lx=YHQsCeWEP0q7eZbfz1S9OS2625Lrk4BR5-MVF+jXZw+g@mail.gmail.com> <1A32855E5FA08141A8C56E7CF24D442C0F007D83@SCTEX101.st-cloud.dassault-avion.fr> <CAC3Lx=bfbFo5Zciu8T_U0-3gzK2choL0qJZC7==8ixfGrhbYiw@mail.gmail.com> <CA+yPOViM5uojsLY10UTC1RMDb5fCQVcoPMirmh1+eJ7AmMcOLQ@mail.gmail.com>
On Mon, Sep 30, 2013 at 5:35 PM, Virgile Prevosto <virgile.prevosto at m4x.org>wrote: > > * I have a variable "v" erroneously defined in two C files (a.c and > > b.c): what is the expected behaviour of a C compiler and Frama-C in > > such a case? > As often with the C standard, nothing is completely clear. (references > below are made against C99): > Following 6.2.2?5, and ?2, as long as v is not explicitely declared > static in one of the files, it should refer to the same object after > link. In addition, it should not be initialized explicitely in both > files (as per 6.9?5). > That said, 6.9.2?2 seems to indicate that if you only have int v; in a > file (without an explicit extern declaration), it should be treated as > int v = 0;, so that you would end up with a variable defined in both > a.c and b.c. > A quick check suggests that neither gcc nor clang does the latter: as > long as v is explicitely initialized in at most one file, they will > link the program and use this initializer, as does Frama-C. > This is a common compiler extension, listed as ?J.5.11 Multiple external definitions? in the standard itself. This was discussed in this StackOverflow question: http://stackoverflow.com/questions/1490693/tentative-definitions-in-c99-and-linking -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.gforge.inria.fr/pipermail/frama-c-discuss/attachments/20130930/f9dcbbd1/attachment.html>
- References:
- [Frama-c-discuss] Printing all global variables of a set of C files?
- From: dmentre at linux-france.org (David MENTRE)
- [Frama-c-discuss] Printing all global variables of a set of C files?
- From: Dillon.Pariente at dassault-aviation.com (Pariente Dillon)
- [Frama-c-discuss] Printing all global variables of a set of C files?
- From: dmentre at linux-france.org (David MENTRE)
- [Frama-c-discuss] Printing all global variables of a set of C files?
- From: virgile.prevosto at m4x.org (Virgile Prevosto)
- [Frama-c-discuss] Printing all global variables of a set of C files?
- Prev by Date: [Frama-c-discuss] Printing all global variables of a set of C files?
- Next by Date: [Frama-c-discuss] Provers versions
- Previous by thread: [Frama-c-discuss] Printing all global variables of a set of C files?
- Next by thread: [Frama-c-discuss] Printing all global variables of a set of C files?
- Index(es):