Skip to main content
Commonmark migration
Source Link

##Error cases:

Error cases:

##Error cases:

Error cases:

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

This includes changes based on the comments from @Loki Astari@Loki Astari on the previous iteration of this code herehere.

This includes changes based on the comments from @Loki Astari on the previous iteration of this code here.

This includes changes based on the comments from @Loki Astari on the previous iteration of this code here.

deleted 71 characters in body
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

Compile time checking of printf-like format strings

Inspired by this open ticket on boostBoost, this seeks to complete the work there.

Code:

This includes changes based on the comments from @Loki Astari on the previous iteration of this code here.

Here is the below code running on ideone.

Any suggestions on this would be greatly appreciated.

tooToo few arguments:

main.cpp:285:84: error: expression ‘<throw-expression>’ is not a constant-expression
             : throw std::logic_error("too few arguments for provided format string");
main.cpp:285:84: error: expression ‘<throw-expression>’ is not a constant-expression
             : throw std::logic_error("too few arguments for provided format string");

tooToo many arguments:

main.cpp:257:87: error: expression ‘<throw-expression>’ is not a constant-expression
                 throw std::logic_error("too many arguments for provided format string")
main.cpp:257:87: error: expression ‘<throw-expression>’ is not a constant-expression
                 throw std::logic_error("too many arguments for provided format string")

mismatchMismatch between argument type and format:

main.cpp:29:68: error: expression ‘<throw-expression>’ is not a constant-expression
     { return C != c ? throw std::logic_error("invalid fmt for type") : true; } \
                                                                    ^
main.cpp:33:1: note: in expansion of macro ‘SUPPORTED_TYPE’
 SUPPORTED_TYPE(int,               'd');
main.cpp:29:68: error: expression ‘<throw-expression>’ is not a constant-expression
     { return C != c ? throw std::logic_error("invalid fmt for type") : true; } \
                                                                    ^
main.cpp:33:1: note: in expansion of macro ‘SUPPORTED_TYPE’
 SUPPORTED_TYPE(int,               'd');

Compile time checking of printf-like format strings

Inspired by this open ticket on boost, this seeks to complete the work there

Code:

This includes changes based on the comments from @Loki Astari on the previous iteration of this code here

Here is the below code running on ideone

Any suggestions on this would be greatly appreciated.

too few arguments:

main.cpp:285:84: error: expression ‘<throw-expression>’ is not a constant-expression
             : throw std::logic_error("too few arguments for provided format string");

too many arguments:

main.cpp:257:87: error: expression ‘<throw-expression>’ is not a constant-expression
                 throw std::logic_error("too many arguments for provided format string")

mismatch between argument type and format:

main.cpp:29:68: error: expression ‘<throw-expression>’ is not a constant-expression
     { return C != c ? throw std::logic_error("invalid fmt for type") : true; } \
                                                                    ^
main.cpp:33:1: note: in expansion of macro ‘SUPPORTED_TYPE’
 SUPPORTED_TYPE(int,               'd');

Inspired by this open ticket on Boost, this seeks to complete the work there.

This includes changes based on the comments from @Loki Astari on the previous iteration of this code here.

Here is the below code running on ideone.

Too few arguments:

main.cpp:285:84: error: expression ‘<throw-expression>’ is not a constant-expression
             : throw std::logic_error("too few arguments for provided format string");

Too many arguments:

main.cpp:257:87: error: expression ‘<throw-expression>’ is not a constant-expression
                 throw std::logic_error("too many arguments for provided format string")

Mismatch between argument type and format:

main.cpp:29:68: error: expression ‘<throw-expression>’ is not a constant-expression
     { return C != c ? throw std::logic_error("invalid fmt for type") : true; } \
                                                                    ^
main.cpp:33:1: note: in expansion of macro ‘SUPPORTED_TYPE’
 SUPPORTED_TYPE(int,               'd');
add %ll length specifier
Source Link
Steve Lorimer
  • 337
  • 1
  • 4
  • 10
Loading
Tweeted twitter.com/#!/StackCodeReview/status/580945199901347840
Source Link
Steve Lorimer
  • 337
  • 1
  • 4
  • 10
Loading