mirror of
https://github.com/curl/curl.git
synced 2026-04-11 12:01:42 +08:00
examples: make them compile with compatibility functions disabled (Windows)
For MinGW this is `-DNO_OLDNAMES`, with MSVC it is `-D_CRT_DECLARE_NONSTDC_NAMES=0`. There have been some support for this before this patch. After this patch this is extended to all examples. (And also the standalone http/client programs, if here.) Cherry-picked from #15652 Closes #15789
This commit is contained in:
parent
37fb50a858
commit
46093d9e0e
@ -34,9 +34,11 @@
|
||||
#include <curl/curl.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# define FILENO(fp) _fileno(fp)
|
||||
#else
|
||||
# define FILENO(fp) fileno(fp)
|
||||
#undef stat
|
||||
#define stat _stat
|
||||
#undef fstat
|
||||
#define fstat _fstat
|
||||
#define fileno _fileno
|
||||
#endif
|
||||
|
||||
#if LIBCURL_VERSION_NUM < 0x070c03
|
||||
@ -98,7 +100,7 @@ int main(int argc, char **argv)
|
||||
|
||||
/* get the file size of the local file */
|
||||
fp = fopen(file, "rb");
|
||||
fstat(FILENO(fp), &file_info);
|
||||
fstat(fileno(fp), &file_info);
|
||||
|
||||
/* In Windows, this inits the Winsock stuff */
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
@ -30,6 +30,14 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#undef stat
|
||||
#define stat _stat
|
||||
#undef fstat
|
||||
#define fstat _fstat
|
||||
#define fileno _fileno
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
|
||||
@ -31,6 +31,8 @@
|
||||
#include <errno.h>
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#undef stat
|
||||
#define stat _stat
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
@ -38,6 +38,11 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#undef stat
|
||||
#define stat _stat
|
||||
#endif
|
||||
|
||||
/* curl stuff */
|
||||
#include <curl/curl.h>
|
||||
#include <curl/mprintf.h>
|
||||
|
||||
@ -30,6 +30,11 @@
|
||||
#include <sys/stat.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#undef stat
|
||||
#define stat _stat
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This example shows an HTTP PUT operation. PUTs a file given as a command
|
||||
* line argument to the URL also given on the command line.
|
||||
|
||||
@ -37,6 +37,10 @@
|
||||
#include <unistd.h> /* getopt() */
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define strdup _strdup
|
||||
#endif
|
||||
|
||||
#ifndef CURLPIPE_MULTIPLEX
|
||||
#error "too old libcurl, cannot do HTTP/2 server push!"
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user