English 中文(简体)
CURL “Expected token ”, got __type of__" in QT
原标题:CURL "Expected token ) , got __typeof__ " in QT
  • 时间:2011-04-10 21:41:59
  •  标签:
  • c++
  • qt
  • curl

我制定计划,从QT的一个地点下载一个档案,但由于QT图书馆没有工作,我决定使用CURL。 根据有关网站文件部分的实例之一,我提出了以下守则:

下载者。

#ifndef DOWNLOADER_H
#define DOWNLOADER_H

// Curl includes
#include "curl/curl.h"
#include "curl/types.h"
#include "curl/easy.h"

#include <QString>
#include <QObject>

class Downloader : QObject
{
    Q_OBJECT

public:
    Downloader();
    void DownloadFile(QString url, QString directory);

signals:
    void DownloadProgress(int downloaded, int total, QString message);
    void DownloadComplete();

private:
    void downProg(double t, double d, double ultotal, double ulnow);
    void read(void *ptr, size_t size, size_t nmemb, FILE *stream);
    void write(void *ptr, size_t size, size_t nmemb, FILE *stream);
};

#endif // DOWNLOADER_H

下载者。

#include "下载者。"

// Curl includes
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>

Downloader::Downloader()
{

}

void Downloader::DownloadFile(QString url, QString directory) {
    CURL *curl;
    CURLcode res;
    FILE *outFile;
    //gchar *url = ptr;
    QString outFileName = directory + "/tempDL/minecraft.jar";

    curl = curl_easy_init();
    if (curl) {
        outFile = fopen(outFileName.toLocal8Bit().data(), "w");

        char *urlC = url.toLocal8Bit().data();
        curl_easy_setopt(curl, CURLOPT_URL, urlC);
    }
}

void Downloader::downProg(double t, double d, double ultotal, double ulnow) {

}

void Downloader::read(void *ptr, size_t size, size_t nmemb, FILE *stream) {

}

void Downloader::write(void *ptr, size_t size, size_t nmemb, FILE *stream) {

}

甚至在建筑前,QT 造物人告诉我,当我上下线时:curl_easy_setopt(curl, CURLOPT_URL, urlC);。 www.un.org/Depts/DGACM/index_french.htm

然后,在汇编该方案时,我收到<代码>。 Id 退回1份出境状况

在 little了一点之后,我怀疑这可能是某种定义性发言,但我无法在将他们从我的班子中除去后找到解决办法。

And this is my last resort for a file downloader, so I really need to make this work.

<><>Edit>:

在审查了汇编材料后,我发现如下。 我认为这可能有助于:

WARNING: Failure to find: Fetcher/http_fetcher.h

WARNING: Failure to find: Fetcher/http_error_codes.h

WARNING: Failure to find: Fetcher/http_fetcher.h

WARNING: Failure to find: Fetcher/http_error_codes.h

而且,在评论了有问题的法典范围后,发现2号错误似乎是由于这一法典线造成的:

curl = curl_easy_init();

<>Update:

After fooling around with this for days, it has done nothing but frustrate me. I ve decided to just try and get the default QT functions to work again instead of fooling with getting this to work. Thanks for your help.

问题回答

Probably the best way to diagnose this issue is to do a preprocess-only compilation. I assume you re using G++ so you should try the -E switch and output to a file. Then take a look at the file to see what the curl_easy_setopt line looks like.

UPDATE: For QT creator you could save off the temporary files created during compilation by updating your .pro file to include this option:

QMAKE_CXXFLAGS += -save-temps

http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html 海湾合作委员会:

Store the usual “temporary” intermediate files permanently; place them in the current directory and name them based on the source file. Thus, compiling foo.c with `-c -save-temps would produce files foo.i and foo.s, as well as foo.o. This creates a preprocessed foo.i output file even though the compiler now normally uses an integrated preprocessor.

<<>code>___ 类型 是海湾合作委员会汇编者的延伸,由CLURL使用。 这意味着,海合会将编纂《欧洲空间法中心法典》,但其他C++级单位(如Qt造物公司)将在《欧洲空间法中心法典》上cho。 签署,但并非关键。

第二次失败“共2:我返回了1个离职状态”,其中不包括一个原因;你应全面引用。 我期望的是,你会想与卢爱阵图书馆连接,但这只是一位受过教育的学者。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签