Changes between Version 7 and Version 8 of WimplicitFunctionDeclaration


Ignore:
Timestamp:
Jan 29, 2022, 6:26:25 AM (2 years ago)
Author:
ryandesign (Ryan Carsten Schmidt)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WimplicitFunctionDeclaration

    v7 v8  
    216216== Add names to implicit declaration whitelist ==
    217217
    218 In cases where you have confirmed that a function name is not declared by the include file which should declare it, for a certain macOS SDK, then add that name to whitelists in the MacPorts codebase. This means that, when the compiler generates a `-Wimplicit-function-declaration` warning for that name, MacPorts will not elevate that warning to the `main.log`. Thus it will not cause concern to MacPorts users who use ports which test for that fucntion name.
    219 
    220 The whitelists are in the MacPorts codebase at `[https://github.com/macports/macports-ports/tree/master/_resources/port1.0/checks/implicit_function_declaration _resources/port1.0/checks/implicit_function_declaration]`. There is a separate whitelist for each version of the macOS SDK: macOS 10.5, macOS 10.14, macOS 11.0 (stored as macOS 11), etc. Each whitelist is a text file containing a list of C language function names, one per line, in lexical order.
    221 
    222 To add a name to the whitelist, first convince yourself that the name is in fact no declared by the include file which should declare it, by creating a brief test program which uses that function. Compile that file with a compiler invocation similar to what MacPorts uses, including `-Werror`. The compiler will implicitly add `-Wimplicit-function-declaration` if it is recent enough to be able to compile ARM code. The compilation should fail with an error message like,
    223 
    224 {{{
    225 warning: implicitly declaring library function '…' with type '…'
    226       [-Wimplicit-function-declaration]
     218In cases where you have confirmed that a function name is not declared by the include file which should declare it, for a certain macOS SDK, then add that name to whitelists in the MacPorts ports tree. This means that, when the compiler generates a `-Wimplicit-function-declaration` warning for that name, MacPorts will not display that warning in the terminal output. Thus it will not cause concern to MacPorts users who use ports which test for that fucntion name.
     219
     220The whitelists are [browser:macports-ports/_resources/port1.0/checks/implicit_function_declaration in the ports tree]. There is a separate whitelist for each version of the macOS SDK: Mac OS X 10.5, macOS 10.14, macOS 11, etc. Each whitelist is a text file containing a list of C language function names, one per line, in lexical order.
     221
     222To add a name to the whitelist, first convince yourself that the name is in fact not declared by the include file which should declare it, by creating and compiling a brief test program which uses that function. Observe if you get a warning or error message like:
     223
     224{{{
     225error: implicitly declaring library function '…' with type '…' [-Werror,-Wimplicit-function-declaration]
     226}}}
     227
     228or:
     229
     230{{{
     231error: implicit declaration of function '…' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    227232}}}
    228233
    229234You may be able to test using multiple different versions of the macOS SDK. That is good. It is desireable to add a function name to all the whitelists to which it applies.
    230235
    231 Then create a Pull Request modifying the whitelist file(s) appropriate for the version(s) of the macOS SDK which you have tested. The change will be simple: to add a line to the file, inserting a new line with the function name, in the correct lexical order. This change will take effect when the user downloads a new version of the MacPorts base code. It applies to all ports, when configured on the version of macOS which corresponds to the whitelist file.
     236Then create a Pull Request modifying the whitelist file(s) appropriate for the version(s) of the macOS SDK which you have tested. The change will be simple: to add a line to the file, inserting a new line with the function name, in the correct lexical order. This change will take effect when the user updates their ports tree. It applies to all ports, when configured on the version of macOS which corresponds to the whitelist file.
    232237
    233238
     
    239244}}}
    240245
    241 This adds the function name (in this example, `strchr` to the whitelist for the current Portfile, regardless of macOS SDK version.
    242 
    243 **TODO**: explain when it is better to change the whitelists, and when it is better to add a `configure.checks.implicit_function_declaration.whitelist-append` to the Portfile.
     246This adds the function name (in this example, `strchr`) to the whitelist for the current Portfile, regardless of macOS SDK version. Do this if the reason why this function should be ignored is specific to this port, rather than to the macOS version. For example, configure scripts generated with the latest version of autoconf will complain erroneously about the implicit declaration of `strchr` because the latest version of autoconf deliberately tries to use `strchr` without including the right header in order to see how the compiler reacts to that.
    244247
    245248== Respond by filing upstream bug reports ==