Error C2061: Syntaxfehler : Bezeichner 'acosf' bei der Verwendung von cURL

Ich versuche zu lernen, über cURL und fand einige code-online, dass ich wollte, um zu kompilieren in Visual Studio, aber ich bekomme eine Reihe von seltsamen Fehler. Ich habe versucht, googeln den Fehler, aber konnte nicht finden, dass in Bezug auf mein Problem. Ich installierte cURL-Bibliotheken okay, aber wenn ich versuche, dieses Programm auszuführen:

#include <curl/curl.h>
#include <fstream>
#include <sstream>
#include <iostream>

//callback function writes data to a std::ostream
static size_t data_write(void* buf, size_t size, size_t nmemb, void* userp)
{
    if(userp)
    {
        std::ostream& os = *static_cast<std::ostream*>(userp);
        std::streamsize len = size * nmemb;
        if(os.write(static_cast<char*>(buf), len))
            return len;
    }

    return 0;
}

/**
 * timeout is in seconds
 **/
CURLcode curl_read(const std::string& url, std::ostream& os, long timeout = 30)
{
    CURLcode code(CURLE_FAILED_INIT);
    CURL* curl = curl_easy_init();

    if(curl)
    {
        if(CURLE_OK == (code = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &data_write))
        && CURLE_OK == (code = curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L))
        && CURLE_OK == (code = curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L))
        && CURLE_OK == (code = curl_easy_setopt(curl, CURLOPT_FILE, &os))
        && CURLE_OK == (code = curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout))
        && CURLE_OK == (code = curl_easy_setopt(curl, CURLOPT_URL, url.c_str())))
        {
            code = curl_easy_perform(curl);
        }
        curl_easy_cleanup(curl);
    }
    return code;
}

int main()
{
    curl_global_init(CURL_GLOBAL_ALL);

    std::ofstream ofs("output.html");
    if(CURLE_OK == curl_read("http://google.com", ofs))
    {
        //Web page successfully written to file
    }

    std::ostringstream oss;
    if(CURLE_OK == curl_read("http://google.com", oss))
    {
        //Web page successfully written to string
        std::string html = oss.str();
    }

    if(CURLE_OK == curl_read("http://google.com", std::cout))
    {
        //Web page successfully written to standard output (console?)
    }

    curl_global_cleanup();
}

Bekomme ich die folgende Liste von Fehlern:

1>------ Build started: Project: cURL.c, Configuration: Debug Win32 ------
1>  main.c
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xtgmath.h(111): warning C4602: #pragma pop_macro : 'new' no previous #pragma push_macro for this identifier
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xtgmath.h(112): warning C4193: #pragma warning(pop) : no matching '#pragma warning(push)'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xtgmath.h(113): warning C4161: #pragma pack(pop...) : more pops than pushes
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(28): error C2061: syntax error : identifier 'acosf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(28): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(28): error C2061: syntax error : identifier 'asinf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(29): error C2061: syntax error : identifier 'atanf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(29): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(29): error C2061: syntax error : identifier 'atan2f'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(29): error C2061: syntax error : identifier 'ceilf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(30): error C2061: syntax error : identifier 'cosf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(30): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(30): error C2061: syntax error : identifier 'coshf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(30): error C2061: syntax error : identifier 'expf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(31): error C2061: syntax error : identifier 'fabsf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(31): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(31): error C2061: syntax error : identifier 'floorf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(31): error C2061: syntax error : identifier 'fmodf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(32): error C2061: syntax error : identifier 'frexpf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(32): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(32): error C2061: syntax error : identifier 'ldexpf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(32): error C2061: syntax error : identifier 'logf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(33): error C2061: syntax error : identifier 'log10f'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(33): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(33): error C2061: syntax error : identifier 'modff'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(33): error C2061: syntax error : identifier 'powf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(34): error C2061: syntax error : identifier 'sinf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(34): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(34): error C2061: syntax error : identifier 'sinhf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(34): error C2061: syntax error : identifier 'sqrtf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(35): error C2061: syntax error : identifier 'tanf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(35): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(35): error C2061: syntax error : identifier 'tanhf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(37): error C2061: syntax error : identifier 'acosl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(37): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(37): error C2061: syntax error : identifier 'asinl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(38): error C2061: syntax error : identifier 'atanl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(38): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(38): error C2061: syntax error : identifier 'atan2l'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(38): error C2061: syntax error : identifier 'ceill'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(39): error C2061: syntax error : identifier 'cosl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(39): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(39): error C2061: syntax error : identifier 'coshl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(39): error C2061: syntax error : identifier 'expl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(40): error C2061: syntax error : identifier 'fabsl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(40): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(40): error C2061: syntax error : identifier 'floorl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(40): error C2061: syntax error : identifier 'fmodl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(41): error C2061: syntax error : identifier 'frexpl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(41): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(41): error C2061: syntax error : identifier 'ldexpl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(41): error C2061: syntax error : identifier 'logl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(42): error C2061: syntax error : identifier 'log10l'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(42): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(42): error C2061: syntax error : identifier 'modfl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(42): error C2061: syntax error : identifier 'powl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(43): error C2061: syntax error : identifier 'sinl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(43): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(43): error C2061: syntax error : identifier 'sinhl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(43): error C2061: syntax error : identifier 'sqrtl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(44): error C2061: syntax error : identifier 'tanl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(44): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(44): error C2061: syntax error : identifier 'tanhl'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(46): error C2061: syntax error : identifier 'abs'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(46): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(48): error C2061: syntax error : identifier 'acos'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(48): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(48): error C2061: syntax error : identifier 'asin'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(49): error C2061: syntax error : identifier 'atan'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(49): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(49): error C2061: syntax error : identifier 'atan2'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(49): error C2061: syntax error : identifier 'ceil'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(50): error C2061: syntax error : identifier 'cos'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(50): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(50): error C2061: syntax error : identifier 'cosh'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(50): error C2061: syntax error : identifier 'exp'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(51): error C2061: syntax error : identifier 'fabs'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(51): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(51): error C2061: syntax error : identifier 'floor'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(51): error C2061: syntax error : identifier 'fmod'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(52): error C2061: syntax error : identifier 'frexp'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(52): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(52): error C2061: syntax error : identifier 'ldexp'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(52): error C2061: syntax error : identifier 'log'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(53): error C2061: syntax error : identifier 'log10'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(53): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(53): error C2061: syntax error : identifier 'modf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(53): error C2061: syntax error : identifier 'pow'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(54): error C2061: syntax error : identifier 'sin'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(54): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(54): error C2061: syntax error : identifier 'sinh'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(54): error C2061: syntax error : identifier 'sqrt'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(55): error C2061: syntax error : identifier 'tan'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(55): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(55): error C2061: syntax error : identifier 'tanh'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(57): error C2061: syntax error : identifier 'hypot'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(57): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cmath(57): error C2061: syntax error : identifier 'hypotf'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdio(36): error C2054: expected '(' to follow 'using'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdio(38): error C2061: syntax error : identifier 'using'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdio(38): error C2054: expected '(' to follow 'using'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdio(39): error C2061: syntax error : identifier 'clearerr'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdio(39): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdio(39): error C2061: syntax error : identifier 'fclose'
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdio(39): fatal error C1003: error count exceeds 100; stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Was das problem sein könnte?

BEARBEITEN:
Programm ohne Fehler:

#include <stdio.h>
#include <curl/curl.h>
//#include <curl.h>
//#include <curlbuild.h>

int main(void)
{
  CURL *curl;
  CURLcode res;

  curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com");
    //example.com is redirected, so we tell libcurl to follow redirection  
    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);

    //Perform the request, res will get the return code  
    res = curl_easy_perform(curl);
    //Check for errors  
    if(res != CURLE_OK)
      fprintf(stderr, "curl_easy_perform() failed: %s\n",
              curl_easy_strerror(res));

    //always cleanup  
    curl_easy_cleanup(curl);
  }
  return 0;
}
  • Ihre cURL-Bibliothek versucht, mit C99 - float Funktionen, die nicht durch den compiler runtime Bibliothek. C89 definiert acos(); C99 definiert acosf() und acosl() auch, aber Sie haben Sie nicht zur Verfügung. Sie müssen, um herauszufinden, wie cURL zu kompilieren, damit es nicht erwarten, dass diese Funktionen verwendet werden, oder Sie werden haben, um Ihnen zu schreiben: float acosf(float x) { return acos(x); } Spülen und wiederholen — bis zum überdruss. Sie haben dann, um das link-Zeile, um Ihre Funktionen nach der cURL-Bibliothek verknüpft wurde. (Kommentar Hinzugefügt, gelöscht, readded...)
  • Tut mir Leid verwirrend, kommentieren, beantworten, und dann die Umkehrung Entscheidungen auf Sie. Mein schlechtes! Sie Fragen: "gibt es eine Möglichkeit diese Funktionen damit der compiler Sie sehen kann? Ich kann nicht laden Sie Sie irgendwo?" — Vernünftige Frage: ich weiß nicht, ob es die irgendwo zum downloaden aus. Ich bin mir nicht ganz sicher, was Los ist, auf einen Blick. Sie haben syntax-Fehler, wo ich war, die Diagnose von link-Zeit-Fehler — also das problem ist nicht ganz das, was ich dachte, es war. Dennoch, MSVC ist ein C89 compiler kein C99 oder C11-compiler, so ist es im Zusammenhang mit dem problem sagte ich, aber nicht genau das, was ich sagte.
  • Kein problem, ich denke, ich Verdiene diese Kopfschmerzen für die Verwendung von Windows auf dem ersten Platz. Ich kann einfach nicht glauben, dass die Microsoft nicht unterstützen würden etwas so wichtig wie diese.
  • Gibt es eine Möglichkeit, ändern Sie das Programm so, dass es nicht den Aufruf dieser C99-Funktionen, behält aber seine Funktionalität?
  • Es ist merkwürdig, dass alle die Fehler, die in der Microsoft-Header. Ich würde vermuten, dass etwas in der curl-Header ist die Kollision mit etwas in die MS-Header. Haben Sie versucht, die Umschaltung der Reihenfolge der header-Dateien?
  • Ich habe nicht die aktuelle header-Dateien, da ich die Dateien über "VC++ - Verzeichnisse" - Reiter unter "Include-Verzeichnisse".
  • Ich meine, Sie setzen #include <curl/curl.h> erste in Ihrem code, versuchen, es letzten. Könnte helfen, diagnostisch, auch wenn es nicht das problem zu beheben.
  • Ich versuchte jede permutation, und die Fehler sind immer noch da.
  • Sie sind da, wenn Sie ausschließen #include <curl/curl.h>? Ich Beginn mich zu Fragen, ob Sie verbockt haben Ihre compiler-installation irgendwie. Keine der Fehlermeldungen beziehen sich auf eine curl-header, es ist alles microsoft-Headern, so scheint es mir. Oder hast du versucht zu installieren curl in der microsoft-Ordner?
  • Sie sind ja, was soll ich tun?
  • Versuchen Sie, erstellen Sie ein neues Projekt, sehen, ob das auch Probleme mit sich. Wenn dem so ist, dann denke ich, Sie sind nur zu haben, um eine Neuinstallation Ihres Compilers. Dann neu installieren, curl, aber dieses mal nicht versuchen, es zu installieren in der gleichen Stelle wie Ihre compiler.
  • Vielleicht gibt es einen name-clash zwischen einem curl header-und einer MS-header. Schade, wenn wahr. In VC++ - Verzeichnisse die curl-Verzeichnisse sollte nach dem MS-Verzeichnisse.
  • Das Programm, das ich Hinzugefügt als edit oben gibt keine Fehler und nutzt locken und meine anderen Programme funktionieren, also denke ich nicht, dass der compiler ist beschädigt und muss neu installiert werden.
  • Warte mal, ich habe gerade etwas bemerkt, Sie kompilieren eine Datei namens main.c, aber es ist eindeutig C++ - code. Ändern Sie den Namen der Datei zu main.cpp!
  • Du bist der Mann! Das war es, danke Bruder.

InformationsquelleAutor Urler | 2013-09-14
Schreibe einen Kommentar