Menu

#24 Compile time argument check for fail_if() etc

(default)
closed
5
2015-12-25
2008-04-08
code_serf
No

The GCC compiler (and possibly some other compiler) supports the attribute __attribute__ ((format (printf, string_idx, first_to_check))) which let the compiler check that the arguments to a printf-like function has an argument list that fits the format string. This is very handy and would be a desirable feature for the fail_if(), fail_unless() and similar functions.

Discussion

  • code_serf

    code_serf - 2008-04-10

    Logged In: YES
    user_id=2057756
    Originator: YES

    I have a works-for-me solution. Actually it works a LOT better for me. I'm aware that it may not work in all environments. I use Debian Linux and GCC 4.1.2. I have made a patch (attached) that is to be applied to check.c and check.h.in rev 433. If it is to be used it will probably need to be conditionally compiled only for the compilers/precompilers/environments that support it. However, in those environments I think it could be very useful. /A
    File Added: check.c

     
  • code_serf

    code_serf - 2008-04-10

    Logged In: YES
    user_id=2057756
    Originator: YES

    File Added: check.diff

     
  • code_serf

    code_serf - 2008-04-10
     
  • code_serf

    code_serf - 2008-04-10

    Logged In: YES
    user_id=2057756
    Originator: YES

    The attached file with the patch should be check.diff not check.c. /A

     
  • Branden Archer

    Branden Archer - 2015-12-25
    • status: open --> closed
    • Group: --> (default)
     
  • Branden Archer

    Branden Archer - 2015-12-25

    This is a duplicate of bug #107.

     

Log in to post a comment.

MongoDB Logo MongoDB