Search code examples
c++pointersawesomium

Awesomium c++: syntax error : missing ';' before '*'


I'm trying to integrate c++ code with awesomium functionalities, but I get many errors. It seems that VisualStudio doesn't like my definition/declaration of the WebCore element. I copied it from http://wiki.awesomium.com/tutorials/tutorial-1-hello-awesomium.html. I have simplified the code until this, and I still get the errors.

SimpleClass.cpp:

#include <Awesomium/WebCore.h>
include "SimpleClass.h"
using namespace Awesomium;

CSimpleClass::CSimpleClass(){   
    WebCore *web_core = WebCore::Initialize(WebConfig());
}
CSimpleClass::~CSimpleClass(){
}

SimpleClass.h:

class CSimpleClass
{
public:
    CSimpleClass(void);
    ~CSimpleClass(void);
    WebCore *web_core;
};

Thanks!


Solution

  • Change your SimpleClass.h header to read:

    #pragma once
    #ifndef SIMPLECLASS_H
    #define SIMPLECLASS_H
    
    // forward declarations
    namespace Awesomium{
    class WebCore;
    }
    
    class CSimpleClass
    {
    public:
        CSimpleClass(void);
        ~CSimpleClass(void);
        Awesomium::WebCore *web_core;
    };
    
    #endif /* SIMPLECLASS_H */
    

    That way you announce to your compiler that there exists a type WebCore in the namespace Awesonium, and then you can use it to declare the member pointer CSimpleClass::web_core.