JonnyCplusplus
JonnyCplusplus

Reputation: 881

error: ‘xxx’ does not name a type

I have a weird problem I don't understand. I am copying over some C code to a C++ class and cannot get past this error "does not name a type" ... I hope I copied enough code for this to make sense, original program is ~1000 lines

Error is .. error: ‘HTTPContext’ does not name a type

The line of the error is "HTTPContext MainWindow::*find_rtp_session_with_url(const char *url, const char *session_id)"

className.h:

class MainWindow : public QMainWindow
{
    Q_OBJECT

 public:

     typedef struct HTTPContext{
         int fd;
     }HTTPContext;

     HTTPContext *find_rtp_session_with_url(const char *url,
                                              const char *session_id);
};

className.cpp

#include "className.h"

HTTPContext MainWindow::*find_rtp_session_with_url(const char *url,
                                          const char *session_id)
{
     HTTPContext *rtp_c;  

}

Upvotes: 0

Views: 1953

Answers (2)

Nikolai Fetissov
Nikolai Fetissov

Reputation: 84239

You need to say

MainWindow::HTTPContext* MainWindow::find_rtp_session_with_url( ...

since it's an inner class. Also you don't have to use typedef there:

struct HTTPContext {
    int fd;
};

is enough to name a type in C++.

Upvotes: 2

Michael Krelin - hacker
Michael Krelin - hacker

Reputation: 143299

HTTPContext is declared in class scope, so to use in the function definition in global scope you need specify it explicitly:

MainWindow::HTTPContext *MainWindow::find_rtp_session_with_url...

Upvotes: 5

Related Questions