Jump to content
  • Advertisement
Sign in to follow this  
yellowstar

Compiling Errors[Quit]

This topic is 3921 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am getting compiler errors, when I try to compile my DLL. And I have no clue why. Errors
dllmain.cpp:167: error: expected unqualified-id before string constant

dllmain.cpp:167: error: expected `,' or `;' before string constant
dllmain.cpp:172: error: expected unqualified-id before string constant
dllmain.cpp:172: error: expected `,' or `;' before string constant




Source
#undef DLLIMPORT
#define DLLIMPORT extern "C" __declspec(dllexport)

GLuint textures[1];

class CRender : public CRenderMod
{
      public:
             
             CRender();
             ~CRender();
             
             bool RenderInit(SEViewportsPtr* ptr);
             bool RenderFInit(void* dat);
             bool RenderDeInit();
             bool RenderFDeInit(ModComm *co);
             int RenderDraw(int vi);
             int RenderStep();
             void RenderReshape(int w,int h);
             int RenderKeys(unsigned char key,int x,int y);
             int RenderKeysSpecial(int key,int x,int y);
};

CRender::CRender()
{
                  
}
CRender::~CRender()
{
                   
}

bool CRender::RenderFInit(void* ptr)
{
     ...
}
bool CRender::RenderInit(SEViewportsPtr* ptr)
{
     ...
}
bool CRender::RenderFDeInit(ModComm *modComm)
{
     ...
}
bool CRender::RenderDeInit()
{
      ...
}

int CRender::RenderDraw(int vindex)
{
     ...
}
int CRender::RenderStep()
{
     
     ...
     
}
void CRender::RenderReshape(int width, int height)
{
    ...
}
int CRender::RenderKeys(unsigned char key, int x, int y)
{
   ...
}
int CRender::RenderKeysSpecial(int key, int x, int y)
{
     
     ...
}

DLLIMPORT bool UseClass()//XXXXXXXX
{
return 1;
}

DLLIMPORT CRenderMod *GetClass()//XXXXX
{
          return new CRender;
}
//These exported functions are the trouble makers!




#ifndef _H_CRENDERMOD
#define _H_CRENDERMOD

class CRenderMod
{
      public:
             CRenderMod(){};
             ~CRenderMod(){};
             
             virtual bool RenderInit(SEViewportsPtr*) = 0;
             virtual bool RenderFInit(void*) = 0;
             virtual bool RenderDeInit() = 0;
             virtual bool RenderFDeInit(ModComm*) = 0;
             virtual int RenderDraw(int) = 0;
             virtual int RenderStep() = 0;
             virtual void RenderReshape(int,int) = 0;
             virtual int RenderKeys(unsigned char,int,int) = 0;
             virtual int RenderKeysSpecial(int,int,int) = 0;
};

#endif



[Edited by - yellowstar on September 30, 2007 2:15:05 PM]

Share this post


Link to post
Share on other sites
Advertisement
In my experience, unqualified id errors usually mean that a namespace or class/struct name should be included in order to use a function/class. Have you checked this? Maybe you should include a 'using <namespace>;' or check that you are using class names correctly.

Otherwise without more information it is difficult to determine what the problem could be.

Shouldn't your method definitions for CRender, for example, instead of


bool renderFInit(void* ptr)
{
....
}


be


bool CRender::renderFInit(void* ptr)
{
....
}


Actually, I've noted that you've given inlined definitions...I can't really tell what the problem is, but the compiler must be getting confused between the 'externed' functions and the identically-signatured CRender class inlined methods. Are you sure that all these signatures are correct? Maybe the 'externed' functions are for CRenderMod?, which is used to return a DLLIMPORT?

--random

[Edited by - random_thinker on September 25, 2007 7:27:11 AM]

Share this post


Link to post
Share on other sites

DLLIMPORT CRenderMod *GetClass()////XXXXX
{
return (CRender*)malloc(sizeof(CRender));
}



That is a bad idea, considering your class has both a constructor and a (probably virtual) destructor. You need to either use new to ensure the constructor is called, or use placement new with the pointer returned from malloc (along with a complementary explicit destructor call and free()).

This isn't the source of your current error, but will cause trouble eventually.

Share this post


Link to post
Share on other sites
what compiler are you using?

i've tried reproducing your errors using g++ and .net 2003 and it compiles ok (of course, replacing the missing classes with dummy ones and so on). the only method of reproducing those errors is by mixing the order or DLLIMPORT and function return type so that it reads:


bool DLLIMPORT UseClass()/////XXXXX
{
return 1;
}


Share this post


Link to post
Share on other sites
I am using Dev-Cpp.

I fixed the above problems,
and updated the source in my first post.
(GetClass, the extra functions, and added the constructor and destructor)
(The reason why I was using malloc, instead of new,
was because the last time I used new, for a class,
I got linker errors. But, this time, it seems it work okay.
(Since I am getting compiler errors,
I have no way of knowing if it really works now,
since those previous errors were linker errors.))

The parent class is being included
before this code.
(parent class source has been added to my first post)

It dosen't matter wether or not I have the define
before or after the return type,
I still get the same error.

[Edited by - yellowstar on September 26, 2007 7:23:48 PM]

Share this post


Link to post
Share on other sites
I tried changing the virtual functions in the parent class,
to pure virtual functions.

But that didn't do anything.

I tried commenting out the class,
and the include for the parent class,
but that didn't get rid of these errors.


Basicly,
I am trying to use a mechanism similar to
using classes for plugins.

The host,(the DLL which uses this DLL)
uses UseClass to determine
wether or not this DLL uses a class.

It assumes no
when it dosen't detect UseClass.

But when it does detect it,
it decides that by calling that
function. It then decides by the return value.

When it decides yes,
it does the following:

It grabs a new instance of the class,
by calling GetClass.
It then copys the address of that instance
into a global struct,
which is used when needed.

But, when no,
it does the following:

It attempts to do the above,
except with a built-in class.
It uses the same DLL as above.
This code is exported functions.
For every pure virtual function,
there is a equallivant exported function
in the DLL.

Share this post


Link to post
Share on other sites
Have you heard of this thing called "Word Wrap"? [smile]

I'd highly recommend changing compilers to Visual Studio 2005. It's far more standards compiant, and is a lot better supported.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!