Skip to content

Commit

Permalink
Don't #define snprintf in VS 2015 builds.
Browse files Browse the repository at this point in the history
The function snprintf is not available in Visual Studio prior to VS
2015. In some places this omission is dealt with with a #define to map
snprintf to _snprintf. This was never a good idea (_snprintf doesn't
guarantee null-termination) and with VS 2015 it is not even legal.

This change conditionally disables one instance of this remapping.

The build errors that occur without this change are:

stdio.h(1926): warning C4005: 'snprintf': macro redefinition
stdio.h(1926): note: command-line arguments:  see previous
definition of 'snprintf'
stdio.h(1929): fatal error C1189: #error:  Macro definition of
snprintf conflicts with Standard Library function declaration

R=scottmg@chromium.org
BUG=440500

Review URL: https://codereview.chromium.org/1069433002

Cr-Commit-Position: refs/heads/master@{#324157}
  • Loading branch information
randomascii authored and Commit bot committed Apr 8, 2015
1 parent 3b3e16c commit 2622e27
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
11 changes: 8 additions & 3 deletions content/content_shell.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,14 @@
'dependencies': [ '../build/linux/system.gyp:x11' ],
}],
['OS=="win"', {
'defines': [
# This seems like a hack, but this is what Safari Win does.
'snprintf=_snprintf',
'conditions': [
['MSVS_VERSION < "2015"', {
'defines': [
# This seems like a hack, but this is what Safari Win does.
# Luckily it is no longer needed/allowed with VS 2015.
'snprintf=_snprintf',
],
}],
],
'sources': [
'shell/tools/plugin/win/TestNetscapePlugin.def',
Expand Down
11 changes: 9 additions & 2 deletions third_party/libexif/libexif.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,16 @@
'sources': [
'libexif.def',
],
'conditions': [
['MSVS_VERSION < "2015"', {
'defines': [
# This seems like a hack, but this is what Safari Win does.
# Luckily it is no longer needed/allowed with VS 2015.
'snprintf=_snprintf',
],
}],
],
'defines': [
# This seems like a hack, but this is what WebKit Win does.
'snprintf=_snprintf',
'inline=__inline',
],
'msvs_disabled_warnings': [
Expand Down

0 comments on commit 2622e27

Please sign in to comment.