4

I'm new to C++ as to Qt. I have the following problem: I want to instantiate a CLEyeCameraCapture object within the Qt header public part, however I get heaps of syntax errors from CLEyeCameraCapture.h.

I get the following (german) syntax errrors:

CLEyeCameraCapture.h(7) : error C2146: Syntaxfehler: Fehlendes ';' vor Bezeichner '_windowName' CLEyeCameraCapture.h(7) : error C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: "default-int" wird von C++ nicht unterstützt.

CLEyeCameraCapture.h(7): error C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: "default-int" wird von C++ nicht unterstützt.

CLEyeCameraCapture.h(8) : error C2146: Syntaxfehler: Fehlendes ';' vor Bezeichner '_cameraGUID' CLEyeCameraCapture.h(8) : error C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: "default-int" wird von C++ nicht unterstützt.

...and so on...

Thanks in advance for any help. Here is my code:

qtdevc.h (header of my application class)

#ifndef QTDEVC_H
#define QTDEVC_H

#include <QtGui/QMainWindow>
#include "ui_qtdevc.h"
#include <QString>
#include <QDebug>
#include <CLEyeCameraCapture.h>
#include <stdafx.h>

class qtDEVC : public QMainWindow
{
    Q_OBJECT

public:
    qtDEVC(QWidget *parent = 0, Qt::WFlags flags = 0);
    ~qtDEVC();
    Ui::qtDEVCClass ui;
    CLEyeCameraCapture::CLeyeCameraCapture cam;

private:
    QPushButton *PushButton_startCam;
    QPushButton *PushButton_stopCam;
    QPushButton *PushButton_startLogging;
    QPushButton *PushButton_quit;
    QLineEdit *lineEditID;


// begin new code
public slots:
    int startCam();
    void stopCam();
    void quit();
// end new code

};

#endif // QTDEVC_H

CLEyeCameraCapture.h

#ifndef CLEYECAMERACAPTURE_H
#define CLEYECAMERACAPTURE_H

// Sample camera capture class
class CLEyeCameraCapture
{
    CHAR _windowName[256];
    GUID _cameraGUID;
    CLEyeCameraInstance _cam;
    CLEyeCameraColorMode _mode;
    CLEyeCameraResolution _resolution;
    float _fps;
    HANDLE _hThread;
    bool _running;
    std::string _participant;
public:
    CLEyeCameraCapture(LPSTR windowName, GUID cameraGUID, CLEyeCameraColorMode mode, CLEyeCameraResolution resolution, float fps) :
        _cameraGUID(cameraGUID), _cam(NULL), _mode(mode), _resolution(resolution), _fps(fps), _running(false)
    {
        strcpy(_windowName, windowName);
    }

    double GetRandomNormalized();
    bool StartCapture(std::string ID);
    void StopCapture();
    void IncrementCameraParameter(int param);
    void DecrementCameraParameter(int param);
    void Run();
    static DWORD WINAPI CaptureThread(LPVOID instance);
};

My Qt App (not cleaned up yet)

#include "qtdevc.h"
#include <QtGui>
#include <QDebug>
#include <QtGui/QApplication>
#include "stdafx.h"
#include "CLEyeCameraCapture.h"
using namespace std;

qtDEVC::qtDEVC(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
{
    ui.setupUi(this);
    connect (ui.pushButton_startCam, SIGNAL( clicked() ),this,SLOT( startCam() ) );
    connect (ui.pushButton_quit, SIGNAL( clicked() ),this,SLOT( quit() ) );
    connect (ui.pushButton_stopCam, SIGNAL ( clicked() ),this,SLOT( stopCam() ) );
}

qtDEVC::~qtDEVC()
{
}

//get ID of participant
int qtDEVC::startCam()
{
    //qt part

    //ui.startCam->setText("Hi!");
    QString ID;
    //get qString Participant Number
    ID = ui.lineEditID->text();
    //convert to standard string
    std::string IDString = ID.toLocal8Bit().constData();
    //qDebug()<<ID;
    ui.lineEditID->setDisabled(true);
    ui.pushButton_startCam->setDisabled(true);


    //moved this to here from main
    CLEyeCameraCapture *cam[2] = { NULL };
    srand(GetTickCount());
    // Query for number of connected cameras

...

edit

including

"#include " before "#include " in qDEVC.h

solved the problem with the syntax errors in compilation, but now i get errors C2146, C3210 and C2602 when tryin to instanciate

CLEyeCameraCapture::CLeyeCameraCapture cam;

what is the correct way ?

CLEyeCameraCapture::CLeyeCameraCapture *cam[2]; ??
refuzee
  • 408
  • 4
  • 15
  • 1
    Show us the minimal code which is causing the problem. – Uchia Itachi Aug 27 '13 at 09:42
  • What is that `Q_OBJECT` in the first header file? – Uchia Itachi Aug 27 '13 at 09:46
  • Posting everything won't solve things... Can you figure out what snippet is giving problems..? – NREZ Aug 27 '13 at 09:47
  • Include "#include " before "#include " in qDEVC.h may solve the compilation issue – Ashif Aug 27 '13 at 09:47
  • olives hint fixed the compilation issue.thanks. I cannot find the right way to instanciate CLEyeCameraCapture. I get a `Syntaxfehler: Fehlendes ';' vor Bezeichner > 'cam'` `CLEyeCameraCapture::CLEyeCameraCapture cam; //CLEyeCameraCapture::CLEyeCameraCapture *cam[2] = {NULL};??` – refuzee Aug 27 '13 at 10:34
  • i get an [error C3210](http://bit.ly/1djvqcQ) and an [error C2602](http://bit.ly/18XDNpo) coming with this – refuzee Aug 27 '13 at 11:03

2 Answers2

2

To fix your compilation error,

Please Include "#include <stdafx.h>" before "#include <CLEyeCameraCapture.h>" in qDEVC.h.

for more info Compiler Error C2146

Rule: Best practice to include standard headers first, then your own headers.C++ Header order

Community
  • 1
  • 1
Ashif
  • 1,652
  • 14
  • 30
  • thanks that helped but I'm still continuing to struggle.. see edit. – refuzee Aug 27 '13 at 11:09
  • Please reorder as per the rule, stdafx.h, then Qt, then CLEyeCameraCapture.h, then qtDev.h ? and compile.. – Ashif Aug 27 '13 at 11:17
  • #include #include #include "ui_qtdevc.h" #include gives me the same errors as in the edit. i really think my construction of instanciating the CLEyeCameraCapture class is wrong error C2602: 'CLEyeCameraCapture::{ctor}'is not a member of a base class of 'qtDEVC' – refuzee Aug 27 '13 at 11:25
  • error C2602: Please replace "CLEyeCameraCapture::CLeyeCameraCapture cam" to "CLeyeCameraCapture cam;" – Ashif Aug 27 '13 at 11:47
  • then define default contructor CLEyeCameraCapture{} – Ashif Aug 27 '13 at 11:48
  • in combination with using `#pragma once` in CLEyeCameraCapture.h this worked (defining a default constructor). I still can not find a way to globally access this variable in _qtdevc.cpp_ – refuzee Aug 27 '13 at 13:39
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/36350/discussion-between-olive-and-refuzee) – Ashif Aug 27 '13 at 16:39
0

Your compiler has no clue what CHAR or GUID is. Include the necessary Windows header files to let the compiler know the definition of these datatypes. Probably including just windows.h could be enough.

Kurt Pattyn
  • 2,758
  • 2
  • 30
  • 42