bug-gnulib
[Top][All Lists]
Advanced

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

Re: warnings in unit tests


From: Bruno Haible
Subject: Re: warnings in unit tests
Date: Thu, 10 Jun 2021 22:05:32 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; )

Dmitry V. Levin wrote:
> Unlike many other gcc warnings, -Wmissing-prototypes is especially useful
> because it doesn't report false positives, so I don't see why one may want
> to turn -Wmissing-prototypes off.

Sometimes a function in a test is not used on some platforms. What are the
possible ways to deal with it?

(1) The test function could be put into a #if. This #if condition needs
    to be updated in some circumstances.
    => This approach (which I would use in lib/ code) is not zero-cost.

(2) The test function can be made 'static'; then we get a compiler warning
    about an unused function (already with '-Wall', IIRC).

(3) The test function can be made global; then we have no warning.
    But -Wmissing-prototypes makes it into a warning.

(4) Then we need to add a prototype to fix that warning.

You see my point? These are small considerations each time, but they
contribute to making test authoring+maintenance a hassle. And they have
no benefit (as I said, in a test that consists of a single compilation
unit, linked against one or more .a files).

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]