googletest icon indicating copy to clipboard operation
googletest copied to clipboard

Getting googletest code can be compiled with -Wundef option

Open lygstate opened this issue 2 years ago • 3 comments
trafficstars

Signed-off-by: Yonggang Luo [email protected]

lygstate avatar Nov 24 '22 10:11 lygstate

The windows CI also fixed by this MR

lygstate avatar Nov 24 '22 22:11 lygstate

  1. This contains changes beyond the minimal code required to enable -Wundef (e.g. edits to build files, adding underscores to struct fields, etc.). Could we reduce it to just change the spurious macros?
  2. Since we use the pattern #if defined(__FOO) && __FOO for external macros, could we use it for googletest macros as well? Instead of attempting to define them to 0.

dinord avatar Dec 20 '22 10:12 dinord

  1. This contains changes beyond the minimal code required to enable -Wundef (e.g. edits to build files, adding underscores to struct fields, etc.). Could we reduce it to just change the spurious macros?
  2. Since we use the pattern #if defined(__FOO) && __FOO for external macros, could we use it for googletest macros as well? Instead of attempting to define them to 0.

define them to 0 is better than #if defined(__FOO) && __FOO because we can use -Wundef to detect if the invalid macro are used

lygstate avatar Dec 20 '22 17:12 lygstate

@thughes @martijnvels Please take a look at this MR

lygstate avatar Feb 09 '23 06:02 lygstate

cc @dinord

lygstate avatar Feb 22 '23 03:02 lygstate

This should now be fixed as of commit d92a270d2d9d6bb7ed3bf7dc3f698028550a65ef.

thughes avatar Mar 06 '23 18:03 thughes

@thughes There is an issue, the bazel didn't guard -Wundef option # Enable Warn if an undefined identifier is evaluated in an #if directive. Such identifiers are replaced with zero. "//:msvc_compiler": [], "//conditions:default": ["-Wundef"],

lygstate avatar Mar 06 '23 19:03 lygstate

@lygstate Should be fixed in commit 678c1c73de2cf004d58f5dbbef299083997d924a and a798c2f10200b6293a5cc236b5f41b26c1ae7378.

thughes avatar Mar 08 '23 00:03 thughes