This commit is contained in:
Daniel Lemire 2026-02-24 11:56:10 -05:00
parent ec664092eb
commit c99403b8af
4 changed files with 24 additions and 24 deletions

View File

@ -1,5 +1,5 @@
#ifndef __FAST_FLOAT_STRTOD_H__
#define __FAST_FLOAT_STRTOD_H__
#ifndef FAST_FLOAT_STRTOD_H__
#define FAST_FLOAT_STRTOD_H__
#if defined(__cplusplus)
extern "C" {
@ -28,4 +28,4 @@ double fast_float_strtod(const char *in, char **out);
}
#endif
#endif /* __FAST_FLOAT_STRTOD_H__ */
#endif /* FAST_FLOAT_STRTOD_H__ */

View File

@ -1,7 +1,7 @@
add_library(fast_float_strtod STATIC fast_float_strtod.cpp)
target_link_libraries(fast_float_strtod PRIVATE fast_float)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU" AND NOT WIN32)
target_link_options(fast_float_strtod PRIVATE -nostdlib++)
endif()

View File

@ -110,7 +110,7 @@ add_subdirectory(build_tests)
add_subdirectory(bloat_analysis)
add_executable(strtod_test strtod_test.c)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU" AND NOT WIN32)
target_link_options(strtod_test PUBLIC -nostdlib++)
endif()
target_link_libraries(strtod_test PUBLIC fast_float_strtod)

View File

@ -4,25 +4,25 @@
#include <errno.h>
int main() {
// Test successful conversion
const char *str1 = "3.14159";
char *end1;
errno = 0;
double d1 = fast_float_strtod(str1, &end1);
printf("Input: %s\n", str1);
printf("Converted: %f\n", d1);
printf("End pointer: %s\n", end1);
printf("errno: %d\n", errno);
// Test successful conversion
const char *str1 = "3.14159";
char *end1;
errno = 0;
double d1 = fast_float_strtod(str1, &end1);
printf("Input: %s\n", str1);
printf("Converted: %f\n", d1);
printf("End pointer: %s\n", end1);
printf("errno: %d\n", errno);
// Test invalid input
const char *str2 = "invalid";
char *end2;
errno = 0;
double d2 = fast_float_strtod(str2, &end2);
printf("\nInput: %s\n", str2);
printf("Converted: %f\n", d2);
printf("End pointer: %s\n", end2);
printf("errno: %d\n", errno);
// Test invalid input
const char *str2 = "invalid";
char *end2;
errno = 0;
double d2 = fast_float_strtod(str2, &end2);
printf("\nInput: %s\n", str2);
printf("Converted: %f\n", d2);
printf("End pointer: %s\n", end2);
printf("errno: %d\n", errno);
return 0;
return 0;
}