View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015659CMakeCMakepublic2015-07-22 17:342016-03-07 09:12
ReporterAlex Lamaison 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformWindowsOSOS Version
Product VersionCMake 3.1.3 
Target VersionFixed in Version 
Summary0015659: Visual Studio 2015: check_function_exists doesn't work for stdio functions
Descriptioncheck_function_exists worked with previous versions of VS and correctly detected the absence of presence of stdio functions like the printf/scanf families, but with VS2015, those functions are always 'not found'

With Visual Studio 2015, those functions are now defined *inline* in stdio.h. This means that CheckFunctionExists.c, which doesn't included stdio.h, can't find any definition of the function to link with. Previously this would have linked with the symbol in the CRT.
Steps To ReproduceAdd check_function_exists(snprintf) to a project.
Configure with VS2015 generator.
It should say 'Looking for snprintf - found'.
Instead it says 'Looking for snprintf - not found'.
Additional InformationA workaround is to add legacy_stdio_definitions.lib to CMAKE_REQUIRED_LIBRARIES. However, that is not ideal because it requires knowing that library is available and required in the first place. That defeats the object of feature detection.

More info here: https://msdn.microsoft.com/en-us/library/bb531344.aspx [^]
TagsNo tags attached.
Attached Files

 Relationships
has duplicate 0015671closed cmake does not find _vsnprintf 
has duplicate 0015772closed snprintf on msvc14 compiler 

  Notes
(0039164)
Brad King (manager)
2015-07-23 08:41

Use CheckSymbolExists instead. That allows one to include a header.
(0039187)
Alex Lamaison (reporter)
2015-07-29 16:01

Thanks. That worked :)
(0040603)
Robert Maynard (manager)
2016-03-07 09:12

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2015-07-22 17:34 Alex Lamaison New Issue
2015-07-23 08:41 Brad King Note Added: 0039164
2015-07-29 16:01 Alex Lamaison Note Added: 0039187
2015-07-30 08:47 Brad King Status new => resolved
2015-07-30 08:47 Brad King Resolution open => no change required
2015-07-30 08:58 Brad King Relationship added has duplicate 0015671
2015-10-07 11:02 Gregor Jasny Relationship added has duplicate 0015772
2016-03-07 09:12 Robert Maynard Note Added: 0040603
2016-03-07 09:12 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team